fn identity_for_exchange(cred: &ClusterCredential) -> Result<Identity> {
    let pkey = PKey::private_key_from_pem(cred.client_key_data.as_bytes())
        .context("error creating private key from pem")?;
    let x509 = X509::from_pem(cred.client_certificate_data.as_bytes())
        .context("error creating x509 from pem")?;

    let pkcs_cert = Pkcs12::builder()
        .build("", "friendly-name", &pkey, &x509)
        .context("Error building Pkcs12 from private key and x509")?;
    let identity = Identity::from_pkcs12(
        &pkcs_cert
            .to_der()
            .context("error creating der from pkcs12")?,
        "",
    )
    .context("error creating identity from der-formatted pkcs12")?;
    Ok(identity)
}
/// identity_for_exchange parses the JSON output of the credential exchange and returns the Identity.
///
/// Note: to create an identity, need to go via a pkcs12 currently.
/// https://github.com/sfackler/rust-native-tls/issues/27#issuecomment-324262673
identity_for_exchange parses the JSON output of the credential exchange and returns the Identity.
Note: to create an identity, need to go via a pkcs12 currently.
identity_for_exchange parses the JSON output of the credential exchange and returns the Identity . Note : to create an identity need to go via a pkcs12 currently .
fn identity_for_exchange(cred: &ClusterCredential) -> Result<Identity> {
    let pkey = PKey::private_key_from_pem(cred.client_key_data.as_bytes())
        .context("error creating private key from pem")?;
    let x509 = X509::from_pem(cred.client_certificate_data.as_bytes())
        .context("error creating x509 from pem")?;
    let pkcs_cert = Pkcs12::builder()
        .build("", "friendly-name", &pkey, &x509)
        .context("Error building Pkcs12 from private key and x509")?;
    let identity = Identity::from_pkcs12(
        &pkcs_cert
            .to_der()
            .context("error creating der from pkcs12")?,
        "",
    )
    .context("error creating identity from der-formatted pkcs12")?;
    Ok(identity)
}
fn identity_for_exchange ( cred : & ClusterCredential ) -> Result < Identity > { let pkey = PKey :: private_key_from_pem ( cred . client_key_data . as_bytes ( ) ) . context ( " " ) ? ; let x509 = X509 :: from_pem ( cred . client_certificate_data . as_bytes ( ) ) . context ( " " ) ? ; let pkcs_cert = Pkcs12 :: builder ( ) . build ( " " , " " , & pkey , & x509 ) . context ( " " ) ? ; let identity = Identity :: from_pkcs12 ( & pkcs_cert . to_der ( ) . context ( " " ) ? , " " , ) . context ( " " ) ? ; Ok ( identity ) }
identity_for_exchange parses the JSON output of the credential exchange and returns the Identity.
identity_for_exchange parses the JSON output of the credential exchange and returns the Identity .
cred
&ClusterCredential