diff options
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(); |