ssl: add get_peer_certificate()

This commit is contained in:
Cody P Schafer 2014-11-24 15:48:08 -05:00
parent c6696eb029
commit fd14cc77f3
1 changed files with 12 additions and 1 deletions

View File

@ -8,7 +8,7 @@ use sync::one::{Once, ONCE_INIT};
use bio::{MemBio};
use ffi;
use ssl::error::{SslError, SslSessionClosed, StreamError};
use x509::{X509StoreContext, X509FileType};
use x509::{X509StoreContext, X509FileType, X509};
pub mod error;
#[cfg(test)]
@ -370,6 +370,17 @@ impl Ssl {
}
}
pub fn get_peer_certificate(&self) -> Option<X509> {
unsafe {
let ptr = ffi::SSL_get_peer_certificate(self.ssl);
if ptr.is_null() {
None
} else {
Some(X509::new(ptr, true))
}
}
}
}
#[deriving(FromPrimitive)]