diff options
| author | Manuel Schölling <[email protected]> | 2015-04-15 22:54:03 +0200 |
|---|---|---|
| committer | Manuel Schölling <[email protected]> | 2015-04-15 22:59:07 +0200 |
| commit | 7db00b97ba4a5e513e2a8bd555bd2b2c36bc0afa (patch) | |
| tree | 56fdf39753142c496084d554f6feeb836786ec46 /openssl/src/x509/mod.rs | |
| parent | Fix nightly build issues (diff) | |
| download | rust-openssl-7db00b97ba4a5e513e2a8bd555bd2b2c36bc0afa.tar.xz rust-openssl-7db00b97ba4a5e513e2a8bd555bd2b2c36bc0afa.zip | |
Add X509::public_key()
Diffstat (limited to 'openssl/src/x509/mod.rs')
| -rw-r--r-- | openssl/src/x509/mod.rs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/openssl/src/x509/mod.rs b/openssl/src/x509/mod.rs index 50731e48..c0e730f7 100644 --- a/openssl/src/x509/mod.rs +++ b/openssl/src/x509/mod.rs @@ -11,7 +11,7 @@ use asn1::{Asn1Time}; use bio::{MemBio}; use crypto::hash; use crypto::hash::Type as HashType; -use crypto::pkey::{PKey}; +use crypto::pkey::{PKey,Parts}; use crypto::rand::rand_bytes; use ffi; use ssl::error::{SslError, StreamError}; @@ -402,6 +402,13 @@ impl<'ctx> X509<'ctx> { X509Name { x509: self, name: name } } + pub fn public_key(&self) -> PKey { + let pkey = unsafe { ffi::X509_get_pubkey(self.handle) }; + assert!(!pkey.is_null()); + + PKey::from_handle(pkey, Parts::Public) + } + /// Returns certificate fingerprint calculated using provided hash pub fn fingerprint(&self, hash_type: hash::Type) -> Option<Vec<u8>> { let evp = hash_type.evp_md(); |