diff options
| author | Bastian Köcher <[email protected]> | 2018-03-08 12:08:39 +0100 |
|---|---|---|
| committer | Bastian Köcher <[email protected]> | 2018-03-08 12:08:39 +0100 |
| commit | 810ddeb4cad73b5f44d2faa88e3439e45fe3bf66 (patch) | |
| tree | 6c9cbbccea667c3b9c6e3015ef5c8ec935114be6 /openssl/src | |
| parent | Fixes the implementation of `X509StoreContextRef::verify_cert` (diff) | |
| download | rust-openssl-810ddeb4cad73b5f44d2faa88e3439e45fe3bf66.tar.xz rust-openssl-810ddeb4cad73b5f44d2faa88e3439e45fe3bf66.zip | |
Moves `cleanup` into its own function
Diffstat (limited to 'openssl/src')
| -rw-r--r-- | openssl/src/x509/mod.rs | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/openssl/src/x509/mod.rs b/openssl/src/x509/mod.rs index e2c87731..107bfe69 100644 --- a/openssl/src/x509/mod.rs +++ b/openssl/src/x509/mod.rs @@ -108,16 +108,16 @@ impl X509StoreContextRef { } /// Verifies a certificate with the given certificate store. + /// For successive calls to this function, it is required to call `cleanup` in beforehand. + /// /// * `trust` - The certificate store with the trusted certificates. /// * `cert` - The certificate that should be verified. /// * `cert_chain` - The certificates chain. /// - /// This corresponds to [`X509_STORE_CTX_init`] followed by [`X509_verify_cert`] and - /// [`X509_STORE_CTX_cleanup`]. + /// This corresponds to [`X509_STORE_CTX_init`] followed by [`X509_verify_cert`]. /// /// [`X509_STORE_CTX_init`]: https://www.openssl.org/docs/man1.0.2/crypto/X509_STORE_CTX_init.html /// [`X509_verify_cert`]: https://www.openssl.org/docs/man1.0.2/crypto/X509_verify_cert.html - /// [`X509_STORE_CTX_cleanup`]: https://www.openssl.org/docs/man1.0.2/crypto/X509_STORE_CTX_cleanup.html /// /// # Result /// @@ -129,13 +129,22 @@ impl X509StoreContextRef { cert.as_ptr(), cert_chain.as_ptr()))?; cvt(ffi::X509_verify_cert(self.as_ptr()))?; - - ffi::X509_STORE_CTX_cleanup(self.as_ptr()); Ok(()) } } + /// Cleans-up the context. + /// + /// This corresponds to [`X509_STORE_CTX_cleanup`]. + /// + /// [`X509_STORE_CTX_cleanup`]: https://www.openssl.org/docs/man1.0.2/crypto/X509_STORE_CTX_cleanup.html + pub fn cleanup(&mut self) { + unsafe { + ffi::X509_STORE_CTX_cleanup(self.as_ptr()); + } + } + /// Set the error code of the context. /// /// This corresponds to [`X509_STORE_CTX_set_error`]. |