diff options
| author | Steven Fackler <[email protected]> | 2014-11-24 16:05:10 -0500 |
|---|---|---|
| committer | Steven Fackler <[email protected]> | 2014-11-24 16:05:10 -0500 |
| commit | e87639893d7b836d3d6008d7304ec7a16583c4e3 (patch) | |
| tree | 8f9c4ed814010e7308295cf889e968e1b181b192 /src | |
| parent | Add more crate metadata (diff) | |
| parent | ssl: add get_peer_certificate() (diff) | |
| download | rust-openssl-e87639893d7b836d3d6008d7304ec7a16583c4e3.tar.xz rust-openssl-e87639893d7b836d3d6008d7304ec7a16583c4e3.zip | |
Merge pull request #104 from jmesmon/sys
Add get_peer_certificate() and a few ffi methods
Diffstat (limited to 'src')
| -rw-r--r-- | src/bn/mod.rs | 4 | ||||
| -rw-r--r-- | src/ssl/mod.rs | 13 |
2 files changed, 14 insertions, 3 deletions
diff --git a/src/bn/mod.rs b/src/bn/mod.rs index b33f94ce..2536f8a5 100644 --- a/src/bn/mod.rs +++ b/src/bn/mod.rs @@ -1,4 +1,4 @@ -use libc::{c_int, c_ulong}; +use libc::{c_int, c_ulong, c_void}; use std::{fmt, ptr}; use std::c_str::CString; @@ -348,7 +348,7 @@ impl BigNum { assert!(!buf.is_null()); let c_str = CString::new(buf, false); let str = c_str.as_str().unwrap().to_string(); - ffi::CRYPTO_free(buf); + ffi::CRYPTO_free(buf as *mut c_void); str } } 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)] |