From 8d0090faecea5dbcbf87a0446beb2e60828378bc Mon Sep 17 00:00:00 2001 From: Lionel Flandrin Date: Mon, 31 Oct 2016 23:55:00 +0100 Subject: Implement X509StoreContextRef::get_chain --- openssl/src/x509/mod.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'openssl/src') diff --git a/openssl/src/x509/mod.rs b/openssl/src/x509/mod.rs index dcda5913..e27b03d1 100644 --- a/openssl/src/x509/mod.rs +++ b/openssl/src/x509/mod.rs @@ -67,6 +67,28 @@ impl Ref { pub fn error_depth(&self) -> u32 { unsafe { ffi::X509_STORE_CTX_get_error_depth(self.as_ptr()) as u32 } } + + pub fn get_chain(&self) -> Option<&Ref>> { + unsafe { + let chain = self._get_chain(); + + if chain.is_null() { + return None; + } + + Some(Ref::from_ptr(chain)) + } + } + + #[cfg(ossl110)] + unsafe fn _get_chain(&self) -> *mut ffi::stack_st_X509 { + ffi::X509_STORE_CTX_get0_chain(self.as_ptr()) + } + + #[cfg(ossl10x)] + unsafe fn _get_chain(&self) -> *mut ffi::stack_st_X509 { + ffi::X509_STORE_CTX_get_chain(self.as_ptr()) + } } #[allow(non_snake_case)] @@ -468,6 +490,10 @@ impl Borrow> for X509 { &*self } } + +impl Stackable for X509 { + type StackType = ffi::stack_st_X509; +} type_!(X509Name, ffi::X509_NAME, ffi::X509_NAME_free); -- cgit v1.2.3