aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLionel Flandrin <[email protected]>2016-10-31 23:55:00 +0100
committerLionel Flandrin <[email protected]>2016-11-01 21:23:18 +0100
commit8d0090faecea5dbcbf87a0446beb2e60828378bc (patch)
treeefa605236cbd01e524d4269c66858546cf8cdb21
parentReplace GeneralNames by the new Stack API (diff)
downloadrust-openssl-8d0090faecea5dbcbf87a0446beb2e60828378bc.tar.xz
rust-openssl-8d0090faecea5dbcbf87a0446beb2e60828378bc.zip
Implement X509StoreContextRef::get_chain
-rw-r--r--openssl-sys/src/ossl10x.rs1
-rw-r--r--openssl-sys/src/ossl110.rs1
-rw-r--r--openssl/src/x509/mod.rs26
3 files changed, 28 insertions, 0 deletions
diff --git a/openssl-sys/src/ossl10x.rs b/openssl-sys/src/ossl10x.rs
index 241dc782..07fa7d46 100644
--- a/openssl-sys/src/ossl10x.rs
+++ b/openssl-sys/src/ossl10x.rs
@@ -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_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_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_data(x: *mut ::ASN1_STRING) -> *mut c_uchar;
pub fn CRYPTO_add_lock(pointer: *mut c_int,
diff --git a/openssl-sys/src/ossl110.rs b/openssl-sys/src/ossl110.rs
index 7d31b687..1b0d9f34 100644
--- a/openssl-sys/src/ossl110.rs
+++ b/openssl-sys/src/ossl110.rs
@@ -141,6 +141,7 @@ extern {
pub fn X509_up_ref(x: *mut X509) -> 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_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_free(ctx: *mut EVP_MD_CTX);
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<X509StoreContext> {
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<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)]
@@ -468,6 +490,10 @@ impl Borrow<Ref<X509>> for X509 {
&*self
}
}
+
+impl Stackable for X509 {
+ type StackType = ffi::stack_st_X509;
+}
type_!(X509Name, ffi::X509_NAME, ffi::X509_NAME_free);