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

52 lines
14 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="SSL/TLS support."><title>openssl::ssl - 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 ssl</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 ssl</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#examples" title="Examples">Examples</a></li></ul><h3><a href="#structs">Module Items</a></h3><ul class="block"><li><a href="#structs" title="Structs">Structs</a></li><li><a href="#enums" title="Enums">Enums</a></li><li><a href="#functions" title="Functions">Functions</a></li></ul></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="../index.html">In crate openssl</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></div><h1>Module <span>ssl</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/ssl/mod.rs.html#1-4377">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>SSL/TLS support.</p>
<p><code>SslConnector</code> and <code>SslAcceptor</code> should be used in most cases - they handle
configuration of the OpenSSL primitives for you.</p>
<h2 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h2>
<p>To connect as a client to a remote server:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>openssl::ssl::{SslMethod, SslConnector};
<span class="kw">use </span>std::io::{Read, Write};
<span class="kw">use </span>std::net::TcpStream;
<span class="kw">let </span>connector = SslConnector::builder(SslMethod::tls()).unwrap().build();
<span class="kw">let </span>stream = TcpStream::connect(<span class="string">"google.com:443"</span>).unwrap();
<span class="kw">let </span><span class="kw-2">mut </span>stream = connector.connect(<span class="string">"google.com"</span>, stream).unwrap();
stream.write_all(<span class="string">b"GET / HTTP/1.0\r\n\r\n"</span>).unwrap();
<span class="kw">let </span><span class="kw-2">mut </span>res = <span class="macro">vec!</span>[];
stream.read_to_end(<span class="kw-2">&amp;mut </span>res).unwrap();
<span class="macro">println!</span>(<span class="string">"{}"</span>, String::from_utf8_lossy(<span class="kw-2">&amp;</span>res));</code></pre></div>
<p>To accept connections as a server from remote clients:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>openssl::ssl::{SslMethod, SslAcceptor, SslStream, SslFiletype};
<span class="kw">use </span>std::net::{TcpListener, TcpStream};
<span class="kw">use </span>std::sync::Arc;
<span class="kw">use </span>std::thread;
<span class="kw">let </span><span class="kw-2">mut </span>acceptor = SslAcceptor::mozilla_intermediate(SslMethod::tls()).unwrap();
acceptor.set_private_key_file(<span class="string">"key.pem"</span>, SslFiletype::PEM).unwrap();
acceptor.set_certificate_chain_file(<span class="string">"certs.pem"</span>).unwrap();
acceptor.check_private_key().unwrap();
<span class="kw">let </span>acceptor = Arc::new(acceptor.build());
<span class="kw">let </span>listener = TcpListener::bind(<span class="string">"0.0.0.0:8443"</span>).unwrap();
<span class="kw">fn </span>handle_client(stream: SslStream&lt;TcpStream&gt;) {
<span class="comment">// ...
</span>}
<span class="kw">for </span>stream <span class="kw">in </span>listener.incoming() {
<span class="kw">match </span>stream {
<span class="prelude-val">Ok</span>(stream) =&gt; {
<span class="kw">let </span>acceptor = acceptor.clone();
thread::spawn(<span class="kw">move </span>|| {
<span class="kw">let </span>stream = acceptor.accept(stream).unwrap();
handle_client(stream);
});
}
<span class="prelude-val">Err</span>(e) =&gt; { <span class="comment">/* connection failed */ </span>}
}
}</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.AlpnError.html" title="struct openssl::ssl::AlpnError">Alpn<wbr>Error</a></dt><dd>An error returned from an ALPN selection callback.</dd><dt><a class="struct" href="struct.CipherBits.html" title="struct openssl::ssl::CipherBits">Cipher<wbr>Bits</a></dt><dd>Information about the state of a cipher.</dd><dt><a class="struct" href="struct.CipherLists.html" title="struct openssl::ssl::CipherLists">Cipher<wbr>Lists</a></dt><dd>A stack of selected ciphers, and a stack of selected signalling cipher suites</dd><dt><a class="struct" href="struct.ClientHelloResponse.html" title="struct openssl::ssl::ClientHelloResponse">Client<wbr>Hello<wbr>Response</a></dt><dd>The result of a client hello callback.</dd><dt><a class="struct" href="struct.ConnectConfiguration.html" title="struct openssl::ssl::ConnectConfiguration">Connect<wbr>Configuration</a></dt><dd>A type which allows for configuration of a client-side TLS session before connection.</dd><dt><a class="struct" href="struct.Error.html" title="struct openssl::ssl::Error">Error</a></dt><dd>An SSL error.</dd><dt><a class="struct" href="struct.ErrorCode.html" title="struct openssl::ssl::ErrorCode">Error<wbr>Code</a></dt><dd>An error code returned from SSL functions.</dd><dt><a class="struct" href="struct.ExtensionContext.html" title="struct openssl::ssl::ExtensionContext">Extension<wbr>Context</a></dt><dd>Which messages and under which conditions an extension should be added or expected.</dd><dt><a class="struct" href="struct.MidHandshakeSslStream.html" title="struct openssl::ssl::MidHandshakeSslStream">MidHandshake<wbr>SslStream</a></dt><dd>An SSL stream midway through the handshake process.</dd><dt><a class="struct" href="struct.NameType.html" title="struct openssl::ssl::NameType">Name<wbr>Type</a></dt><dd>An identifier of a session name type.</dd><dt><a class="struct" href="struct.ShutdownState.html" title="struct openssl::ssl::ShutdownState">Shutdown<wbr>State</a></dt><dd>The shutdown state of a session.</dd><dt><a class="struct" href="struct.SniError.html" title="struct openssl::ssl::SniError">SniError</a></dt><dd>An error returned from the SNI callback.</dd><dt><a class="struct" href="struct.Ssl.html" title="struct openssl::ssl::Ssl">Ssl</a></dt><dd>The state of an SSL/TLS session.</dd><dt><a class="struct" href="struct.SslAcceptor.html" title="struct openssl::ssl::SslAcceptor">SslAcceptor</a></dt><dd>A type which wraps server-side streams in a TLS session.</dd><dt><a class="struct" href="struct.SslAcceptorBuilder.html" title="struct openssl::ssl::SslAcceptorBuilder">SslAcceptor<wbr>Builder</a></dt><dd>A builder for <code>SslAcceptor</code>s.</dd><dt><a class="struct" href="struct.SslAlert.html" title="struct openssl::ssl::SslAlert">SslAlert</a></dt><dd>An SSL/TLS alert.</dd><dt><a class="struct" href="struct.SslCipher.html" title="struct openssl::ssl::SslCipher">SslCipher</a></dt><dd>Information about a cipher.</dd><dt><a class="struct" href="struct.SslCipherRef.html" title="struct openssl::ssl::SslCipherRef">SslCipher<wbr>Ref</a></dt><dd>Reference to an <a href="struct.SslCipher.html"><code>SslCipher</code></a>.</dd><dt><a class="struct" href="struct.SslConnector.html" title="struct openssl::ssl::SslConnector">SslConnector</a></dt><dd>A type which wraps client-side streams in a TLS session.</dd><dt><a class="struct" href="struct.SslConnectorBuilder.html" title="struct openssl::ssl::SslConnectorBuilder">SslConnector<wbr>Builder</a></dt><dd>A builder for <code>SslConnector</code>s.</dd><dt><a class="struct" href="struct.SslContext.html" title="struct openssl::ssl::SslContext">SslContext</a></dt><dd>A context object for TLS streams.</dd><dt><a class="struct" href="struct.SslContextBuilder.html" title="struct openssl::ssl::SslContextBuilder">SslContext<wbr>Builder</a></dt><dd>A builder for <code>SslContext</code>s.</dd><dt><a class="struct" href="struct.SslContextRef.html" title="struct openssl::ssl::SslContextRef">SslContext<wbr>Ref</a></dt><dd>Reference to <a href="struct.SslContext.html"><code>SslContext</code></a></dd><dt><a class="struct" href="struct.SslFiletype.html" title="struct openssl::ssl::SslFiletype">SslFiletype</a></dt><dd>An identifier of the format of a certificate or key file.</dd><dt><a class="struct" href="struct.SslMethod.html" title="struct openssl::ssl::SslMethod">SslMethod</a></dt><dd>A type specifying the kind of protocol an <code>SslContext</code> will speak.</dd><dt><a class="struct" href="struct.SslMode.html" title="struct openssl::ssl::SslMode">SslMode</a></dt><dd>Options controlling the behavior of an <code>SslContext</code>.</dd><dt><a class="struct" href="struct.SslOptions.html" title="struct openssl::ssl::SslOptions">SslOptions</a></dt><dd>Options controlling the behavior of an <code>SslContext</code>.</dd><dt><a class="struct" href="struct.SslRef.html" title="struct openssl::ssl::SslRef">SslRef</a></dt><dd>Reference to an <a href="struct.Ssl.html"><code>Ssl</code></a>.</dd><dt><a class="struct" href="struct.SslSession.html" title="struct openssl::ssl::SslSession">SslSession</a></dt><dd>An encoded SSL session.</dd><dt><a class="struct" href="struct.SslSessionCacheMode.html" title="struct openssl::ssl::SslSessionCacheMode">SslSession<wbr>Cache<wbr>Mode</a></dt><dd>Options controlling the behavior of session caching.</dd><dt><a class="struct" href="struct.SslSessionRef.html" title="struct openssl::ssl::SslSessionRef">SslSession<wbr>Ref</a></dt><dd>Reference to <a href="struct.SslSession.html"><code>SslSession</code></a>.</dd><dt><a class="struct" href="struct.SslStream.html" title="struct openssl::ssl::SslStream">SslStream</a></dt><dd>A TLS session over a stream.</dd><dt><a class="struct" href="struct.SslStreamBuilder.html" title="struct openssl::ssl::SslStreamBuilder">SslStream<wbr>Builder</a><wbr><span class="stab deprecated" title="">Deprecated</span></dt><dd>A partially constructed <code>SslStream</code>, useful for unusual handshakes.</dd><dt><a class="struct" href="struct.SslVerifyMode.html" title="struct openssl::ssl::SslVerifyMode">SslVerify<wbr>Mode</a></dt><dd>Options controlling the behavior of certificate verification.</dd><dt><a class="struct" href="struct.SslVersion.html" title="struct openssl::ssl::SslVersion">SslVersion</a></dt><dd>An SSL/TLS protocol version.</dd><dt><a class="struct" href="struct.StatusType.html" title="struct openssl::ssl::StatusType">Status<wbr>Type</a></dt><dd>An identifier of a certificate status type.</dd></dl><h2 id="enums" class="section-header">Enums<a href="#enums" class="anchor">§</a></h2><dl class="item-table"><dt><a class="enum" href="enum.HandshakeError.html" title="enum openssl::ssl::HandshakeError">Handshake<wbr>Error</a></dt><dd>An error or intermediate state after a TLS handshake attempt.</dd><dt><a class="enum" href="enum.ShutdownResult.html" title="enum openssl::ssl::ShutdownResult">Shutdown<wbr>Result</a></dt><dd>The result of a shutdown request.</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.cipher_name.html" title="fn openssl::ssl::cipher_name">cipher_<wbr>name</a></dt><dd>Returns the OpenSSL name of a cipher corresponding to an RFC-standard cipher name.</dd><dt><a class="fn" href="fn.select_next_proto.html" title="fn openssl::ssl::select_next_proto">select_<wbr>next_<wbr>proto</a></dt><dd>A standard implementation of protocol selection for Application Layer Protocol Negotiation
(ALPN).</dd></dl></section></div></main></body></html>