fn extract_fingerprint(key: &Path) -> anyhow::Result<Fingerprint> {
    let policy = &mut StandardPolicy::new();
    let cert = Cert::from_file(key).context("Failed to load key from file")?;

    // let secret_keys: Vec<Key<key::SecretParts, key::UnspecifiedRole>> = cert // <- for Rust on CLion
    let secret_keys = cert
        .keys()
        .with_policy(policy, None)
        .for_transport_encryption()
        .for_storage_encryption()
        .secret()
        .alive()
        .revoked(false)
        .into_iter()
        .map(|key| key.key().clone())
        .collect::<Vec<_>>();

    let secret_key = match secret_keys.first() {
        Some(key) => key,
        None => return Err(anyhow!("Failed to find a secret key in file")),
    };
    Ok(secret_key.fingerprint())
}
/// Extract fingerprint of first private key found in file
Extract fingerprint of first private key found in file
Extract fingerprint of first private key found in file
fn extract_fingerprint(key: &Path) -> anyhow::Result<Fingerprint> {
    let policy = &mut StandardPolicy::new();
    let cert = Cert::from_file(key).context("Failed to load key from file")?;
    // let secret_keys: Vec<Key<key::SecretParts, key::UnspecifiedRole>> = cert // <- for Rust on CLion
    let secret_keys = cert
        .keys()
        .with_policy(policy, None)
        .for_transport_encryption()
        .for_storage_encryption()
        .secret()
        .alive()
        .revoked(false)
        .into_iter()
        .map(|key| key.key().clone())
        .collect::<Vec<_>>();
    let secret_key = match secret_keys.first() {
        Some(key) => key,
        None => return Err(anyhow!("Failed to find a secret key in file")),
    };
    Ok(secret_key.fingerprint())
}
fn extract_fingerprint ( key : & Path ) -> anyhow :: Result < Fingerprint > { let policy = & mut StandardPolicy :: new ( ) ; let cert = Cert :: from_file ( key ) . context ( " " ) ? ; // let secret_keys: Vec<Key<key::SecretParts, key::UnspecifiedRole>> = cert // <- for Rust on CLion let secret_keys = cert . keys ( ) . with_policy ( policy , None ) . for_transport_encryption ( ) . for_storage_encryption ( ) . secret ( ) . alive ( ) . revoked ( false ) . into_iter ( ) . map ( | key | key . key ( ) . clone ( ) ) . collect :: < Vec < _ > > ( ) ; let secret_key = match secret_keys . first ( ) { Some ( key ) => key , None => return Err ( anyhow ! ( " " ) ) , } ; Ok ( secret_key . fingerprint ( ) ) }
Extract fingerprint of first private key found in file
Extract fingerprint of first private key found in file
key
&Path
key
&Path