# openssl::x509::store - Rust
API documentation for the Rust `store` mod in crate `openssl`.
Keywords: rust, rustlang, rust-lang, store

# Module openssl::x509::store [−] [src]

Describe a context in which to verify an `X509` certificate.

The `X509` certificate store holds trusted CA certificates used to verify peer certificates.

# Example

    use openssl::x509::store::{X509StoreBuilder, X509Store};
    use openssl::x509::{X509, X509Name};
    use openssl::pkey::PKey;
    use openssl::hash::MessageDigest;
    use openssl::rsa::Rsa;
    use openssl::nid::Nid;

    let rsa = Rsa::generate(2048).unwrap();
    let pkey = PKey::from_rsa(rsa).unwrap();

    let mut name = X509Name::builder().unwrap();
    name.append_entry_by_nid(Nid::COMMONNAME, "foobar.com").unwrap();
    let name = name.build();

    let mut builder = X509::builder().unwrap();
    builder.set_version(2).unwrap();
    builder.set_subject_name(&name).unwrap();
    builder.set_issuer_name(&name).unwrap();
    builder.set_pubkey(&pkey).unwrap();
    builder.sign(&pkey, MessageDigest::sha256()).unwrap();

    let certificate: X509 = builder.build();

    let mut builder = X509StoreBuilder::new().unwrap();
    let _ = builder.add_cert(certificate);

    let store: X509Store = builder.build();

## Structs

HashDir | Marker type corresponding to the `X509_LOOKUP_hash_dir` lookup method.
X509Lookup | Information used by an `X509Store` to look up certificates and CRLs.
X509LookupMethod | Method used to look up certificates and CRLs.
X509LookupMethodRef | Reference to an `X509LookupMethod`.
X509LookupRef | Reference to an `X509Lookup`.
X509Store | A certificate store to hold trusted `X509` certificates.
X509StoreBuilder | A builder type used to construct an `X509Store`.
X509StoreBuilderRef | Reference to an `X509StoreBuilder`.
X509StoreRef | Reference to an `X509Store`.