summaryrefslogtreecommitdiff
path: root/openssl/src/x509/store.rs
diff options
context:
space:
mode:
authorSteven Fackler <sfackler@gmail.com>2017-01-13 19:38:12 -0800
committerSteven Fackler <sfackler@gmail.com>2017-01-14 21:09:38 -0800
commit920ab0d6fb60c17077f43d7f08ad3ff391201689 (patch)
tree2ede3415426f622fe2aff78eaa70a3d64f35a403 /openssl/src/x509/store.rs
parent9942643ab6fbdecb0561fcdc08565d4f154865b3 (diff)
downloadrust-openssl-920ab0d6fb60c17077f43d7f08ad3ff391201689.zip
OCSP functionality
Diffstat (limited to 'openssl/src/x509/store.rs')
-rw-r--r--openssl/src/x509/store.rs35
1 files changed, 34 insertions, 1 deletions
diff --git a/openssl/src/x509/store.rs b/openssl/src/x509/store.rs
index 01eb0e2f..dd08a49b 100644
--- a/openssl/src/x509/store.rs
+++ b/openssl/src/x509/store.rs
@@ -1,13 +1,33 @@
use ffi;
use std::mem;
-use cvt;
+use {cvt, cvt_p};
use error::ErrorStack;
use types::OpenSslTypeRef;
use x509::X509;
type_!(X509StoreBuilder, X509StoreBuilderRef, ffi::X509_STORE, ffi::X509_STORE_free);
+impl X509StoreBuilder {
+ /// Returns a builder for a certificate store.
+ ///
+ /// The store is initially empty.
+ pub fn new() -> Result<X509StoreBuilder, ErrorStack> {
+ unsafe {
+ ffi::init();
+
+ cvt_p(ffi::X509_STORE_new()).map(X509StoreBuilder)
+ }
+ }
+
+ /// Constructs the `X509Store`.
+ pub fn build(self) -> X509Store {
+ let store = X509Store(self.0);
+ mem::forget(self);
+ store
+ }
+}
+
impl X509StoreBuilderRef {
/// Adds a certificate to the certificate store.
pub fn add_cert(&mut self, cert: X509) -> Result<(), ErrorStack> {
@@ -17,4 +37,17 @@ impl X509StoreBuilderRef {
cvt(ffi::X509_STORE_add_cert(self.as_ptr(), ptr)).map(|_| ())
}
}
+
+ /// Load certificates from their default locations.
+ ///
+ /// These locations are read from the `SSL_CERT_FILE` and `SSL_CERT_DIR`
+ /// environment variables if present, or defaults specified at OpenSSL
+ /// build time otherwise.
+ pub fn set_default_paths(&mut self) -> Result<(), ErrorStack> {
+ unsafe {
+ cvt(ffi::X509_STORE_set_default_paths(self.as_ptr())).map(|_| ())
+ }
+ }
}
+
+type_!(X509Store, X509StoreRef, ffi::X509_STORE, ffi::X509_STORE_free);