Files
GopherGate/target/doc/openssl/index.html
2026-02-26 12:00:21 -05:00

98 lines
15 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!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="Bindings to OpenSSL"><title>openssl - 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="../crates.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 crate"><!--[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="#">Crate openssl</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"><ul class="block"><li><a id="all-types" href="all.html">All Items</a></li></ul><section id="rustdoc-toc"><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#building" title="Building">Building</a><ul><li><a href="#vendored" title="Vendored">Vendored</a></li><li><a href="#automatic" title="Automatic">Automatic</a></li><li><a href="#manual" title="Manual">Manual</a></li></ul></li><li><a href="#feature-detection" title="Feature Detection">Feature Detection</a></li></ul><h3><a href="#modules">Crate Items</a></h3><ul class="block"><li><a href="#modules" title="Modules">Modules</a></li><li><a href="#functions" title="Functions">Functions</a></li></ul></section><div id="rustdoc-modnav"></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"><h1>Crate <span>openssl</span>&nbsp;<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/lib.rs.html#1-259">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Bindings to OpenSSL</p>
<p>This crate provides a safe interface to the popular OpenSSL cryptography library. OpenSSL versions 1.0.2 through
3.x.x and LibreSSL versions 3.5 through 4.2.x are supported.</p>
<h2 id="building"><a class="doc-anchor" href="#building">§</a>Building</h2>
<p>Both OpenSSL libraries and headers are required to build this crate. There are multiple options available to locate
OpenSSL.</p>
<h3 id="vendored"><a class="doc-anchor" href="#vendored">§</a>Vendored</h3>
<p>If the <code>vendored</code> Cargo feature is enabled, the <code>openssl-src</code> crate will be used to compile and statically link to
a copy of OpenSSL. The build process requires a C compiler, perl (and perl-core), and make. The OpenSSL version will generally track
the newest OpenSSL release, and changes to the version are <em>not</em> considered breaking changes.</p>
<div class="example-wrap"><pre class="language-toml"><code>[dependencies]
openssl = { version = &quot;0.10&quot;, features = [&quot;vendored&quot;] }</code></pre></div>
<p>The vendored copy will be configured to automatically find a configuration and root certificates at <code>/usr/local/ssl</code>.
This path can be overridden with an environment variable (see the manual section below).
Alternatively, the <code>openssl-probe</code> crate can be used to find root certificates at runtime.</p>
<h3 id="automatic"><a class="doc-anchor" href="#automatic">§</a>Automatic</h3>
<p>The <code>openssl-sys</code> crate will automatically detect OpenSSL installations via Homebrew on macOS and vcpkg on Windows.
Additionally, it will use <code>pkg-config</code> on Unix-like systems to find the system installation.</p>
<div class="example-wrap"><pre class="language-not_rust"><code># macOS (Homebrew)
$ brew install openssl@3
# macOS (MacPorts)
$ sudo port install openssl
# macOS (pkgsrc)
$ sudo pkgin install openssl
# Arch Linux
$ sudo pacman -S pkgconf openssl
# Debian and Ubuntu
$ sudo apt-get install pkg-config libssl-dev
# Fedora
$ sudo dnf install pkgconf perl-FindBin perl-IPC-Cmd openssl-devel
# Alpine Linux
$ apk add pkgconf openssl-dev
# openSUSE
$ sudo zypper in libopenssl-devel</code></pre></div><h3 id="manual"><a class="doc-anchor" href="#manual">§</a>Manual</h3>
<p>A set of environment variables can be used to point <code>openssl-sys</code> towards an OpenSSL installation. They will
override the automatic detection logic.</p>
<ul>
<li><code>OPENSSL_DIR</code> - If specified, the directory of an OpenSSL installation. The directory should contain <code>lib</code> and
<code>include</code> subdirectories containing the libraries and headers respectively.</li>
<li><code>OPENSSL_LIB_DIR</code> and <code>OPENSSL_INCLUDE_DIR</code> - If specified, the directories containing the OpenSSL libraries and
headers respectively. This can be used if the OpenSSL installation is split in a nonstandard directory layout.</li>
<li><code>OPENSSL_STATIC</code> - If set, the crate will statically link to OpenSSL rather than dynamically link.</li>
<li><code>OPENSSL_LIBS</code> - If set, a <code>:</code>-separated list of library names to link to (e.g. <code>ssl:crypto</code>). This can be used
if nonstandard library names were used for whatever reason.</li>
<li><code>OPENSSL_NO_VENDOR</code> - If set, always find OpenSSL in the system, even if the <code>vendored</code> feature is enabled.</li>
</ul>
<p>If the <code>vendored</code> Cargo feature is enabled, the following environment variable can also be used to further configure
the OpenSSL build.</p>
<ul>
<li><code>OPENSSL_CONFIG_DIR</code> - If set, the copy of OpenSSL built by the <code>openssl-src</code> crate will be configured to look for
configuration files and root certificates in this directory.</li>
</ul>
<p>Additionally, these variables can be prefixed with the upper-cased target architecture (e.g.
<code>X86_64_UNKNOWN_LINUX_GNU_OPENSSL_DIR</code>), which can be useful when cross compiling.</p>
<h2 id="feature-detection"><a class="doc-anchor" href="#feature-detection">§</a>Feature Detection</h2>
<p>APIs have been added to and removed from the various supported OpenSSL versions, and this library exposes the
functionality available in the version being linked against. This means that methods, constants, and even modules
will be present when building against one version of OpenSSL but not when building against another! APIs will
document any version-specific availability restrictions.</p>
<p>A build script can be used to detect the OpenSSL or LibreSSL version at compile time if needed. The <code>openssl-sys</code>
crate propagates the version via the <code>DEP_OPENSSL_VERSION_NUMBER</code> and <code>DEP_OPENSSL_LIBRESSL_VERSION_NUMBER</code>
environment variables to build scripts. The version format is a hex-encoding of the OpenSSL release version:
<code>0xMNNFFPPS</code>. For example, version 1.0.2gs encoding is <code>0x1_00_02_07_0</code>.</p>
<p>For example, lets say we want to adjust the TLSv1.3 cipher suites used by a client, but also want to compile
against OpenSSL versions that dont support TLSv1.3:</p>
<p>Cargo.toml:</p>
<div class="example-wrap"><pre class="language-toml"><code>[dependencies]
openssl-sys = &quot;0.9&quot;
openssl = &quot;0.10&quot;</code></pre></div>
<p>build.rs:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>std::env;
<span class="kw">fn </span>main() {
<span class="kw">if let </span><span class="prelude-val">Ok</span>(v) = env::var(<span class="string">"DEP_OPENSSL_VERSION_NUMBER"</span>) {
<span class="kw">let </span>version = u64::from_str_radix(<span class="kw-2">&amp;</span>v, <span class="number">16</span>).unwrap();
<span class="kw">if </span>version &gt;= <span class="number">0x1_01_01_00_0 </span>{
<span class="macro">println!</span>(<span class="string">"cargo:rustc-cfg=openssl111"</span>);
}
}
}</code></pre></div>
<p>lib.rs:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>openssl::ssl::{SslConnector, SslMethod};
<span class="kw">let </span><span class="kw-2">mut </span>ctx = SslConnector::builder(SslMethod::tls()).unwrap();
<span class="comment">// set_ciphersuites was added in OpenSSL 1.1.1, so we can only call it when linking against that version
</span><span class="attr">#[cfg(openssl111)]
</span>ctx.set_ciphersuites(<span class="string">"TLS_AES_256_GCM_SHA384:TLS_AES_128_GCM_SHA256"</span>).unwrap();</code></pre></div></div></details><h2 id="modules" class="section-header">Modules<a href="#modules" class="anchor">§</a></h2><dl class="item-table"><dt><a class="mod" href="aes/index.html" title="mod openssl::aes">aes</a></dt><dd>Low level AES IGE and key wrapping functionality</dd><dt><a class="mod" href="asn1/index.html" title="mod openssl::asn1">asn1</a></dt><dd>Defines the format of certificates</dd><dt><a class="mod" href="base64/index.html" title="mod openssl::base64">base64</a></dt><dd>Base64 encoding support.</dd><dt><a class="mod" href="bn/index.html" title="mod openssl::bn">bn</a></dt><dd>BigNum implementation</dd><dt><a class="mod" href="cipher/index.html" title="mod openssl::cipher">cipher</a></dt><dd>Symmetric ciphers.</dd><dt><a class="mod" href="cipher_ctx/index.html" title="mod openssl::cipher_ctx">cipher_<wbr>ctx</a></dt><dd>The symmetric encryption context.</dd><dt><a class="mod" href="cms/index.html" title="mod openssl::cms">cms</a></dt><dd>SMIME implementation using CMS</dd><dt><a class="mod" href="conf/index.html" title="mod openssl::conf">conf</a></dt><dd>Interface for processing OpenSSL configuration files.</dd><dt><a class="mod" href="derive/index.html" title="mod openssl::derive">derive</a></dt><dd>Shared secret derivation.</dd><dt><a class="mod" href="dh/index.html" title="mod openssl::dh">dh</a></dt><dd>Diffie-Hellman key agreement.</dd><dt><a class="mod" href="dsa/index.html" title="mod openssl::dsa">dsa</a></dt><dd>Digital Signatures</dd><dt><a class="mod" href="ec/index.html" title="mod openssl::ec">ec</a></dt><dd>Elliptic Curve</dd><dt><a class="mod" href="ecdsa/index.html" title="mod openssl::ecdsa">ecdsa</a></dt><dd>Low level Elliptic Curve Digital Signature Algorithm (ECDSA) functions.</dd><dt><a class="mod" href="encrypt/index.html" title="mod openssl::encrypt">encrypt</a></dt><dd>Message encryption.</dd><dt><a class="mod" href="envelope/index.html" title="mod openssl::envelope">envelope</a></dt><dd>Envelope encryption.</dd><dt><a class="mod" href="error/index.html" title="mod openssl::error">error</a></dt><dd>Errors returned by OpenSSL library.</dd><dt><a class="mod" href="ex_data/index.html" title="mod openssl::ex_data">ex_data</a></dt><dt><a class="mod" href="hash/index.html" title="mod openssl::hash">hash</a></dt><dd>Message digest (hash) computation support.</dd><dt><a class="mod" href="kdf/index.html" title="mod openssl::kdf">kdf</a></dt><dt><a class="mod" href="lib_ctx/index.html" title="mod openssl::lib_ctx">lib_ctx</a></dt><dt><a class="mod" href="md/index.html" title="mod openssl::md">md</a></dt><dd>Message digest algorithms.</dd><dt><a class="mod" href="md_ctx/index.html" title="mod openssl::md_ctx">md_ctx</a></dt><dd>The message digest context.</dd><dt><a class="mod" href="memcmp/index.html" title="mod openssl::memcmp">memcmp</a></dt><dd>Utilities to safely compare cryptographic values.</dd><dt><a class="mod" href="nid/index.html" title="mod openssl::nid">nid</a></dt><dd>A collection of numerical identifiers for OpenSSL objects.</dd><dt><a class="mod" href="ocsp/index.html" title="mod openssl::ocsp">ocsp</a></dt><dt><a class="mod" href="pkcs5/index.html" title="mod openssl::pkcs5">pkcs5</a></dt><dt><a class="mod" href="pkcs7/index.html" title="mod openssl::pkcs7">pkcs7</a></dt><dt><a class="mod" href="pkcs12/index.html" title="mod openssl::pkcs12">pkcs12</a></dt><dd>PKCS #12 archives.</dd><dt><a class="mod" href="pkey/index.html" title="mod openssl::pkey">pkey</a></dt><dd>Public/private key processing.</dd><dt><a class="mod" href="pkey_ctx/index.html" title="mod openssl::pkey_ctx">pkey_<wbr>ctx</a></dt><dd>The asymmetric encryption context.</dd><dt><a class="mod" href="provider/index.html" title="mod openssl::provider">provider</a></dt><dt><a class="mod" href="rand/index.html" title="mod openssl::rand">rand</a></dt><dd>Utilities for secure random number generation.</dd><dt><a class="mod" href="rsa/index.html" title="mod openssl::rsa">rsa</a></dt><dd>RivestShamirAdleman cryptosystem</dd><dt><a class="mod" href="sha/index.html" title="mod openssl::sha">sha</a></dt><dd>The SHA family of hashes.</dd><dt><a class="mod" href="sign/index.html" title="mod openssl::sign">sign</a></dt><dd>Message signatures.</dd><dt><a class="mod" href="srtp/index.html" title="mod openssl::srtp">srtp</a></dt><dt><a class="mod" href="ssl/index.html" title="mod openssl::ssl">ssl</a></dt><dd>SSL/TLS support.</dd><dt><a class="mod" href="stack/index.html" title="mod openssl::stack">stack</a></dt><dt><a class="mod" href="string/index.html" title="mod openssl::string">string</a></dt><dt><a class="mod" href="symm/index.html" title="mod openssl::symm">symm</a></dt><dd>High level interface to certain symmetric ciphers.</dd><dt><a class="mod" href="version/index.html" title="mod openssl::version">version</a></dt><dd>Build and version information.</dd><dt><a class="mod" href="x509/index.html" title="mod openssl::x509">x509</a></dt><dd>The standard defining the format of public key certificates.</dd></dl><h2 id="functions" class="section-header">Functions<a href="#functions" class="anchor">§</a></h2><dl class="item-table"><dt><a class="fn" href="fn.init.html" title="fn openssl::init">init</a></dt></dl></section></div></main></body></html>