Skip to content
CryoCryo home
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;
FileWhat it holdsImport
contextTlsConnector, TlsAcceptor — the SSL_CTX ownersimport std::net::tls::context;
streamTlsStream, AlpnProtocolimport std::net::tls::stream;
futureTlsHandshake, TlsRead, TlsWrite, TlsIoimport 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 ssl and crypto to link_libs in its cryoconfig. See ffi::openssl. Nothing here is referenced unless net::tls is used, so non-TLS binaries link without OpenSSL.

For one-shot HTTPS requests that tie resolution, dialling, TLS, and HTTP together, see net::https.