Stdlibnet
net::tls
A thin, safe binding over the system OpenSSL — not a reimplementation. TlsConnector (client) and TlsAcceptor (server) mint TlsStreams, which implement AsyncTransport exactly as TcpStream does, so the HTTP and WebSocket layers run over them unchanged. That is the whole point of routing TLS through the same seam as plaintext TCP.
public module net::tls::stream;
public module net::tls::context;
public module net::tls::future;
| File | What it holds | Import |
|---|---|---|
context | TlsConnector, TlsAcceptor — the SSL_CTX owners | import std::net::tls::context; |
stream | TlsStream, AlpnProtocol | import std::net::tls::stream; |
future | TlsHandshake, TlsRead, TlsWrite, TlsIo | import std::net::tls::future; |
import std::net::tls;
mut connector: TlsConnector = TlsConnector::new()?;
mut tls: TlsStream = await connector.connect(tcp, host)?;
Any binary using this module must add
sslandcryptotolink_libsin itscryoconfig. Seeffi::openssl. Nothing here is referenced unlessnet::tlsis used, so non-TLS binaries link without OpenSSL.
For one-shot HTTPS requests that tie resolution, dialling, TLS, and HTTP together, see net::https.