37 lines
7.9 KiB
HTML
37 lines
7.9 KiB
HTML
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Describe a context in which to verify an `X509` certificate."><title>openssl::x509::store - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../../../" data-static-root-path="../../../static.files/" data-current-crate="openssl" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../../../static.files/storage-e2aeef58.js"></script><script defer src="../sidebar-items.js"></script><script defer src="../../../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../../../static.files/noscript-263c88ec.css"></noscript><link rel="alternate icon" type="image/png" href="../../../static.files/favicon-32x32-eab170b8.png"><link rel="icon" type="image/svg+xml" href="../../../static.files/favicon-044be391.svg"></head><body class="rustdoc mod"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><rustdoc-topbar><h2><a href="#">Module store</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../../openssl/index.html">openssl</a><span class="version">0.10.75</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Module store</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#example" title="Example">Example</a></li></ul><h3><a href="#structs">Module Items</a></h3><ul class="block"><li><a href="#structs" title="Structs">Structs</a></li></ul></section><div id="rustdoc-modnav"><h2><a href="../index.html">In openssl::<wbr>x509</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="../../index.html">openssl</a>::<wbr><a href="../index.html">x509</a></div><h1>Module <span>store</span> <button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../../src/openssl/x509/store.rs.html#1-301">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Describe a context in which to verify an <code>X509</code> certificate.</p>
|
|
<p>The <code>X509</code> certificate store holds trusted CA certificates used to verify
|
|
peer certificates.</p>
|
|
<h2 id="example"><a class="doc-anchor" href="#example">§</a>Example</h2>
|
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>openssl::x509::store::{X509StoreBuilder, X509Store};
|
|
<span class="kw">use </span>openssl::x509::{X509, X509Name};
|
|
<span class="kw">use </span>openssl::asn1::Asn1Time;
|
|
<span class="kw">use </span>openssl::pkey::PKey;
|
|
<span class="kw">use </span>openssl::hash::MessageDigest;
|
|
<span class="kw">use </span>openssl::rsa::Rsa;
|
|
<span class="kw">use </span>openssl::nid::Nid;
|
|
|
|
<span class="kw">let </span>rsa = Rsa::generate(<span class="number">2048</span>).unwrap();
|
|
<span class="kw">let </span>pkey = PKey::from_rsa(rsa).unwrap();
|
|
|
|
<span class="kw">let </span><span class="kw-2">mut </span>name = X509Name::builder().unwrap();
|
|
name.append_entry_by_nid(Nid::COMMONNAME, <span class="string">"foobar.com"</span>).unwrap();
|
|
<span class="kw">let </span>name = name.build();
|
|
|
|
<span class="comment">// Sep 27th, 2016
|
|
</span><span class="kw">let </span>sample_time = Asn1Time::from_unix(<span class="number">1474934400</span>).unwrap();
|
|
|
|
<span class="kw">let </span><span class="kw-2">mut </span>builder = X509::builder().unwrap();
|
|
builder.set_version(<span class="number">2</span>).unwrap();
|
|
builder.set_subject_name(<span class="kw-2">&</span>name).unwrap();
|
|
builder.set_issuer_name(<span class="kw-2">&</span>name).unwrap();
|
|
builder.set_pubkey(<span class="kw-2">&</span>pkey).unwrap();
|
|
builder.set_not_before(<span class="kw-2">&</span>sample_time);
|
|
builder.set_not_after(<span class="kw-2">&</span>sample_time);
|
|
builder.sign(<span class="kw-2">&</span>pkey, MessageDigest::sha256()).unwrap();
|
|
|
|
<span class="kw">let </span>certificate: X509 = builder.build();
|
|
|
|
<span class="kw">let </span><span class="kw-2">mut </span>builder = X509StoreBuilder::new().unwrap();
|
|
<span class="kw">let _ </span>= builder.add_cert(certificate);
|
|
|
|
<span class="kw">let </span>store: X509Store = builder.build();</code></pre></div></div></details><h2 id="structs" class="section-header">Structs<a href="#structs" class="anchor">§</a></h2><dl class="item-table"><dt><a class="struct" href="struct.File.html" title="struct openssl::x509::store::File">File</a></dt><dd>Marker type corresponding to the <a href="https://docs.openssl.org/master/man3/X509_LOOKUP_file/"><code>X509_LOOKUP_file</code></a> lookup method.</dd><dt><a class="struct" href="struct.HashDir.html" title="struct openssl::x509::store::HashDir">HashDir</a></dt><dd>Marker type corresponding to the <a href="https://docs.openssl.org/master/man3/X509_LOOKUP_hash_dir/"><code>X509_LOOKUP_hash_dir</code></a> lookup method.</dd><dt><a class="struct" href="struct.X509Lookup.html" title="struct openssl::x509::store::X509Lookup">X509<wbr>Lookup</a></dt><dd>Information used by an <code>X509Store</code> to look up certificates and CRLs.</dd><dt><a class="struct" href="struct.X509LookupMethod.html" title="struct openssl::x509::store::X509LookupMethod">X509<wbr>Lookup<wbr>Method</a></dt><dd>Method used to look up certificates and CRLs.</dd><dt><a class="struct" href="struct.X509LookupMethodRef.html" title="struct openssl::x509::store::X509LookupMethodRef">X509<wbr>Lookup<wbr>Method<wbr>Ref</a></dt><dd>A reference to an <a href="struct.X509LookupMethod.html" title="struct openssl::x509::store::X509LookupMethod"><code>X509LookupMethod</code></a>.</dd><dt><a class="struct" href="struct.X509LookupRef.html" title="struct openssl::x509::store::X509LookupRef">X509<wbr>Lookup<wbr>Ref</a></dt><dd>A reference to an <a href="struct.X509Lookup.html" title="struct openssl::x509::store::X509Lookup"><code>X509Lookup</code></a>.</dd><dt><a class="struct" href="struct.X509Store.html" title="struct openssl::x509::store::X509Store">X509<wbr>Store</a></dt><dd>A certificate store to hold trusted <code>X509</code> certificates.</dd><dt><a class="struct" href="struct.X509StoreBuilder.html" title="struct openssl::x509::store::X509StoreBuilder">X509<wbr>Store<wbr>Builder</a></dt><dd>A builder type used to construct an <code>X509Store</code>.</dd><dt><a class="struct" href="struct.X509StoreBuilderRef.html" title="struct openssl::x509::store::X509StoreBuilderRef">X509<wbr>Store<wbr>Builder<wbr>Ref</a></dt><dd>A reference to an <a href="struct.X509StoreBuilder.html" title="struct openssl::x509::store::X509StoreBuilder"><code>X509StoreBuilder</code></a>.</dd><dt><a class="struct" href="struct.X509StoreRef.html" title="struct openssl::x509::store::X509StoreRef">X509<wbr>Store<wbr>Ref</a></dt><dd>Reference to an <code>X509Store</code>.</dd></dl></section></div></main></body></html> |