aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCody P Schafer <[email protected]>2014-11-24 15:48:08 -0500
committerCody P Schafer <[email protected]>2014-11-24 15:48:08 -0500
commitfd14cc77f37f4bec78d313106191fbebf72a9284 (patch)
tree8f9c4ed814010e7308295cf889e968e1b181b192 /src
parentsys: add SSL_get_peer_certificate() (diff)
downloadrust-openssl-fd14cc77f37f4bec78d313106191fbebf72a9284.tar.xz
rust-openssl-fd14cc77f37f4bec78d313106191fbebf72a9284.zip
ssl: add get_peer_certificate()
Diffstat (limited to 'src')
-rw-r--r--src/ssl/mod.rs13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/ssl/mod.rs b/src/ssl/mod.rs
index 1f0599b4..8e035466 100644
--- a/src/ssl/mod.rs
+++ b/src/ssl/mod.rs
@@ -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)]