diff options
| author | Benjamin Fry <[email protected]> | 2017-03-19 12:06:41 -0700 |
|---|---|---|
| committer | Bastian Köcher <[email protected]> | 2018-03-07 13:50:12 +0100 |
| commit | 35cad33d518f3b6ecff1a01a4707b35ab834342e (patch) | |
| tree | 804a68c4d415c095b02a073c81b2f7eb77a8b02d | |
| parent | properly version library functions (diff) | |
| download | rust-openssl-35cad33d518f3b6ecff1a01a4707b35ab834342e.tar.xz rust-openssl-35cad33d518f3b6ecff1a01a4707b35ab834342e.zip | |
fix error check
| -rw-r--r-- | openssl-sys/src/lib.rs | 1 | ||||
| -rw-r--r-- | openssl/src/x509/mod.rs | 4 | ||||
| -rw-r--r-- | openssl/src/x509/tests.rs | 5 |
3 files changed, 4 insertions, 6 deletions
diff --git a/openssl-sys/src/lib.rs b/openssl-sys/src/lib.rs index 85ab03f7..c29b60e8 100644 --- a/openssl-sys/src/lib.rs +++ b/openssl-sys/src/lib.rs @@ -2605,7 +2605,6 @@ extern "C" { pub fn X509_sign(x: *mut X509, pkey: *mut EVP_PKEY, md: *const EVP_MD) -> c_int; pub fn X509_get_pubkey(x: *mut X509) -> *mut EVP_PKEY; pub fn X509_to_X509_REQ(x: *mut X509, pkey: *mut EVP_PKEY, md: *const EVP_MD) -> *mut X509_REQ; - #[cfg(not(any(ossl101, libressl)))] pub fn X509_verify_cert(ctx: *mut X509_STORE_CTX) -> c_int; pub fn X509_verify_cert_error_string(n: c_long) -> *const c_char; pub fn X509_get1_ocsp(x: *mut X509) -> *mut stack_st_OPENSSL_STRING; diff --git a/openssl/src/x509/mod.rs b/openssl/src/x509/mod.rs index 1e7c4448..6133e1a3 100644 --- a/openssl/src/x509/mod.rs +++ b/openssl/src/x509/mod.rs @@ -86,11 +86,11 @@ impl X509StoreContextRef { } } - #[cfg(any(all(feature = "v102", ossl102), all(feature = "v110", ossl110)))] pub fn verify_cert(self) -> Result<Option<X509VerifyError>, ErrorStack> { unsafe { - cvt(ffi::X509_verify_cert(self.as_ptr())).map(|_| ()) + try!(cvt(ffi::X509_verify_cert(self.as_ptr())).map(|_| ())) } + Ok(self.error()) } /// Returns the error code of the context. diff --git a/openssl/src/x509/tests.rs b/openssl/src/x509/tests.rs index 2b9d5dd3..b6303ade 100644 --- a/openssl/src/x509/tests.rs +++ b/openssl/src/x509/tests.rs @@ -285,7 +285,6 @@ fn signature() { assert_eq!(algorithm.object().to_string(), "sha256WithRSAEncryption"); } -#[cfg(any(all(feature = "v102", ossl102), all(feature = "v110", ossl110)))] #[test] fn clone_x509() { let cert = include_bytes!("../../test/cert.pem"); @@ -301,11 +300,11 @@ fn test_verify_cert() { let ca = X509::from_pem(ca).unwrap(); let mut store_bldr = X509StoreBuilder::new().unwrap(); - store_bldr.add_cert(ca); + store_bldr.add_cert(ca).unwrap(); let store = store_bldr.build(); let store_ctx_bldr = X509StoreContext::builder().unwrap(); let store_ctx = store_ctx_bldr.build(&store, &cert, &Stack::new().unwrap()).unwrap(); - store_ctx.verify_cert().unwrap(); + assert!(store_ctx.verify_cert().unwrap().is_none()); } |