fn decode_rsa_key(pem_pkcs8: &str) -> Result<PrivateKey, io::Error> {
    let private_keys = pemfile::pkcs8_private_keys(&mut pem_pkcs8.as_bytes());

    match private_keys {
        Ok(mut keys) if !keys.is_empty() => {
            keys.truncate(1);
            Ok(keys.remove(0))
        }
        Ok(_) => Err(io::Error::new(
            io::ErrorKind::InvalidInput,
            "Not enough private keys in PEM",
        )),
        Err(_) => Err(io::Error::new(
            io::ErrorKind::InvalidInput,
            "Error reading key from PEM",
        )),
    }
}
/// Decode a PKCS8 formatted RSA key.
Decode a PKCS8 formatted RSA key.
Decode a PKCS8 formatted RSA key .
fn decode_rsa_key(pem_pkcs8: &str) -> Result<PrivateKey, io::Error> {
    let private_keys = pemfile::pkcs8_private_keys(&mut pem_pkcs8.as_bytes());
    match private_keys {
        Ok(mut keys) if !keys.is_empty() => {
            keys.truncate(1);
            Ok(keys.remove(0))
        }
        Ok(_) => Err(io::Error::new(
            io::ErrorKind::InvalidInput,
            "Not enough private keys in PEM",
        )),
        Err(_) => Err(io::Error::new(
            io::ErrorKind::InvalidInput,
            "Error reading key from PEM",
        )),
    }
}
fn decode_rsa_key ( pem_pkcs8 : & str ) -> Result < PrivateKey , io :: Error > { let private_keys = pemfile :: pkcs8_private_keys ( & mut pem_pkcs8 . as_bytes ( ) ) ; match private_keys { Ok ( mut keys ) if ! keys . is_empty ( ) => { keys . truncate ( 1 ) ; Ok ( keys . remove ( 0 ) ) } Ok ( _ ) => Err ( io :: Error :: new ( io :: ErrorKind :: InvalidInput , " " , ) ) , Err ( _ ) => Err ( io :: Error :: new ( io :: ErrorKind :: InvalidInput , " " , ) ) , } }
Decode a PKCS8 formatted RSA key.
Decode a PKCS8 formatted RSA key .
pem_pkcs8
&str