fix error check

This commit is contained in:
Benjamin Fry 2017-03-19 12:06:41 -07:00 committed by Bastian Köcher
parent 847fac25f8
commit 35cad33d51
3 changed files with 4 additions and 6 deletions

View File

@ -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_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_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; 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(ctx: *mut X509_STORE_CTX) -> c_int;
pub fn X509_verify_cert_error_string(n: c_long) -> *const c_char; 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; pub fn X509_get1_ocsp(x: *mut X509) -> *mut stack_st_OPENSSL_STRING;

View File

@ -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> { pub fn verify_cert(self) -> Result<Option<X509VerifyError>, ErrorStack> {
unsafe { 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. /// Returns the error code of the context.

View File

@ -285,7 +285,6 @@ fn signature() {
assert_eq!(algorithm.object().to_string(), "sha256WithRSAEncryption"); assert_eq!(algorithm.object().to_string(), "sha256WithRSAEncryption");
} }
#[cfg(any(all(feature = "v102", ossl102), all(feature = "v110", ossl110)))]
#[test] #[test]
fn clone_x509() { fn clone_x509() {
let cert = include_bytes!("../../test/cert.pem"); let cert = include_bytes!("../../test/cert.pem");
@ -301,11 +300,11 @@ fn test_verify_cert() {
let ca = X509::from_pem(ca).unwrap(); let ca = X509::from_pem(ca).unwrap();
let mut store_bldr = X509StoreBuilder::new().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 = store_bldr.build();
let store_ctx_bldr = X509StoreContext::builder().unwrap(); let store_ctx_bldr = X509StoreContext::builder().unwrap();
let store_ctx = store_ctx_bldr.build(&store, &cert, &Stack::new().unwrap()).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());
} }