Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/imp/openssl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,10 @@ impl Identity {
let chain = cert_chain.collect();
Ok(Identity { pkey, cert, chain })
}

pub fn from_raw(context: RawType) -> Identity {
Identity { pkey: context.0, cert: context.1, chain: context.2 }
}
}

#[derive(Clone)]
Expand Down
8 changes: 8 additions & 0 deletions src/imp/schannel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ use {TlsAcceptorBuilder, TlsConnectorBuilder};

const SEC_E_NO_CREDENTIALS: u32 = 0x8009030E;

pub type RawType = self::schannel::cert_context::CertContext;

static PROTOCOLS: &'static [Protocol] = &[
Protocol::Ssl3,
Protocol::Tls10,
Expand Down Expand Up @@ -140,6 +142,12 @@ impl Identity {
}
Ok(Identity { cert: context })
}


pub fn from_raw(context: CertContext) -> Identity {
Identity { cert: context }
}

}

// The name of the container must be unique to have multiple active keys.
Expand Down
6 changes: 6 additions & 0 deletions src/imp/security_framework.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ fn convert_protocol(protocol: Protocol) -> SslProtocol {
}
}

pub type RawType = (SecIdentity, Vec<SecCertificate>);

pub struct Error(base::Error);

impl error::Error for Error {
Expand Down Expand Up @@ -148,6 +150,10 @@ impl Identity {
})
}

pub fn from_raw(context: RawType) -> Identity {
Identity { identity: context.0, chain: context.1 }
}

#[cfg(not(target_os = "ios"))]
fn import_options(buf: &[u8], pass: &str) -> Result<Vec<ImportedIdentity>, Error> {
SET_AT_EXIT.call_once(|| {
Expand Down
5 changes: 5 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,11 @@ impl Identity {
let identity = imp::Identity::from_pkcs8(pem, key)?;
Ok(Identity(identity))
}

/// Creates a certificate context out of the raw type available on the platform
pub fn from_raw(context: imp::RawType) -> Identity {
Identity(imp::Identity::from_raw(context))
}
}

/// An X509 certificate.
Expand Down