1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
use ffi; use std::mem; use cvt; use error::ErrorStack; use types::OpenSslTypeRef; use x509::X509; type_!(X509StoreBuilder, X509StoreBuilderRef, ffi::X509_STORE, ffi::X509_STORE_free); impl X509StoreBuilderRef { /// Adds a certificate to the certificate store. pub fn add_cert(&mut self, cert: X509) -> Result<(), ErrorStack> { unsafe { let ptr = cert.as_ptr(); mem::forget(cert); // the cert will be freed inside of X509_STORE_add_cert on error cvt(ffi::X509_STORE_add_cert(self.as_ptr(), ptr)).map(|_| ()) } } }