Implement X509StoreContextRef::get_chain

This commit is contained in:
Lionel Flandrin 2016-10-31 23:55:00 +01:00
parent 36bf0bb387
commit 8d0090faec
3 changed files with 28 additions and 0 deletions

View File

@ -583,6 +583,7 @@ extern {
pub fn X509_get_ext_d2i(x: *mut ::X509, nid: c_int, crit: *mut c_int, idx: *mut c_int) -> *mut c_void; pub fn X509_get_ext_d2i(x: *mut ::X509, nid: c_int, crit: *mut c_int, idx: *mut c_int) -> *mut c_void;
pub fn X509_NAME_get_entry(n: *mut ::X509_NAME, loc: c_int) -> *mut ::X509_NAME_ENTRY; pub fn X509_NAME_get_entry(n: *mut ::X509_NAME, loc: c_int) -> *mut ::X509_NAME_ENTRY;
pub fn X509_NAME_ENTRY_get_data(ne: *mut ::X509_NAME_ENTRY) -> *mut ::ASN1_STRING; pub fn X509_NAME_ENTRY_get_data(ne: *mut ::X509_NAME_ENTRY) -> *mut ::ASN1_STRING;
pub fn X509_STORE_CTX_get_chain(ctx: *mut ::X509_STORE_CTX) -> *mut stack_st_X509;
pub fn ASN1_STRING_to_UTF8(out: *mut *mut c_uchar, s: *mut ::ASN1_STRING) -> c_int; pub fn ASN1_STRING_to_UTF8(out: *mut *mut c_uchar, s: *mut ::ASN1_STRING) -> c_int;
pub fn ASN1_STRING_data(x: *mut ::ASN1_STRING) -> *mut c_uchar; pub fn ASN1_STRING_data(x: *mut ::ASN1_STRING) -> *mut c_uchar;
pub fn CRYPTO_add_lock(pointer: *mut c_int, pub fn CRYPTO_add_lock(pointer: *mut c_int,

View File

@ -141,6 +141,7 @@ extern {
pub fn X509_up_ref(x: *mut X509) -> c_int; pub fn X509_up_ref(x: *mut X509) -> c_int;
pub fn SSL_CTX_up_ref(x: *mut SSL_CTX) -> c_int; pub fn SSL_CTX_up_ref(x: *mut SSL_CTX) -> c_int;
pub fn X509_get0_extensions(req: *const ::X509) -> *const stack_st_X509_EXTENSION; pub fn X509_get0_extensions(req: *const ::X509) -> *const stack_st_X509_EXTENSION;
pub fn X509_STORE_CTX_get0_chain(ctx: *mut ::X509_STORE_CTX) -> *mut stack_st_X509;
pub fn EVP_MD_CTX_new() -> *mut EVP_MD_CTX; pub fn EVP_MD_CTX_new() -> *mut EVP_MD_CTX;
pub fn EVP_MD_CTX_free(ctx: *mut EVP_MD_CTX); pub fn EVP_MD_CTX_free(ctx: *mut EVP_MD_CTX);

View File

@ -67,6 +67,28 @@ impl Ref<X509StoreContext> {
pub fn error_depth(&self) -> u32 { pub fn error_depth(&self) -> u32 {
unsafe { ffi::X509_STORE_CTX_get_error_depth(self.as_ptr()) as u32 } unsafe { ffi::X509_STORE_CTX_get_error_depth(self.as_ptr()) as u32 }
} }
pub fn get_chain(&self) -> Option<&Ref<Stack<X509>>> {
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)] #[allow(non_snake_case)]
@ -468,6 +490,10 @@ impl Borrow<Ref<X509>> for X509 {
&*self &*self
} }
} }
impl Stackable for X509 {
type StackType = ffi::stack_st_X509;
}
type_!(X509Name, ffi::X509_NAME, ffi::X509_NAME_free); type_!(X509Name, ffi::X509_NAME, ffi::X509_NAME_free);