aboutsummaryrefslogtreecommitdiff
path: root/openssl/src/x509/store.rs
blob: 01eb0e2ff078e3d2d2b8a934f49c62980bf8b050 (plain) (blame)
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(|_| ())
        }
    }
}