Commit c2164a48 authored by Steven Fackler's avatar Steven Fackler
Browse files

Add peer_cert_chain

parent a1328341
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -2240,6 +2240,7 @@ extern "C" {
    #[cfg(libressl)]
    pub fn SSL_get_current_compression(ssl: *mut SSL) -> *const libc::c_void;
    pub fn SSL_get_peer_certificate(ssl: *const SSL) -> *mut X509;
    pub fn SSL_get_peer_cert_chain(ssl: *const SSL) -> *mut stack_st_X509;
    pub fn SSL_get_ssl_method(ssl: *mut SSL) -> *const SSL_METHOD;
    pub fn SSL_get_version(ssl: *const SSL) -> *const c_char;
    pub fn SSL_state_string(ssl: *const SSL) -> *const c_char;
+15 −0
Original line number Diff line number Diff line
@@ -1257,6 +1257,21 @@ impl SslRef {
        }
    }

    /// Returns the certificate chain of the peer, if present.
    ///
    /// On the client side, the chain includes the leaf certificate, but on the server side it does
    /// not. Fun!
    pub fn peer_cert_chain(&self) -> Option<&StackRef<X509>> {
        unsafe {
            let ptr = ffi::SSL_get_peer_cert_chain(self.as_ptr());
            if ptr.is_null() {
                None
            } else {
                Some(StackRef::from_ptr(ptr))
            }
        }
    }

    /// Returns the certificate associated with this `Ssl`, if present.
    pub fn certificate(&self) -> Option<&X509Ref> {
        unsafe {