Commit fd14cc77 authored by Cody P Schafer's avatar Cody P Schafer
Browse files

ssl: add get_peer_certificate()

parent c6696eb0
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -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)]