Skip to main content

Module tls

Module tls 

Source
Expand description

TLS termination with certificates that rotate underneath a running origin.

Two things make this more than a wrapper around tokio_rustls.

The first is reload. A ServerConfig is built once and never rebuilt; every handshake asks CertificateResolver which key to present, and that resolver is one ArcSwap deep. Rotating a certificate is therefore a single atomic store: live connections keep the key they negotiated with, the next handshake picks up the new one, and nothing is dropped or rebound. Only the certificate and key can change this way — the ALPN list and the crypto provider are fixed at bind time, because nothing rotates them on a schedule.

The second is that the handshake must not happen on the accept path. axum::serve::Listener::accept is a single future the server awaits in sequence, so terminating TLS inside it would let one slow client hold up every other connection. Handshakes run as spawned tasks under a deadline and a fixed ceiling instead.

Structs§

CertificateResolver
Answers every handshake from a slot that can be replaced underneath it.
CertificateWatch
Keeps the debouncer and its pump alive for as long as its owner lives.
ClientIdentity
A client certificate and key that reload underneath a running caller.
IgnoreTlsEvents
Discards everything, for a caller that wants no reporting.
TlsListener
A bound TLS listener plus the watch that keeps its certificate current.
TlsSettings
Where the certificate and its key live, and how patient the listener is.

Enums§

TlsError
TlsVersion
Supported protocol bounds for TCP TLS. QUIC always uses TLS 1.3.

Traits§

TlsObserver
What a caller learns about certificates and handshakes.

Functions§

load_certificates
Reads a nonempty PEM chain, preserving leaf-first certificate order.
load_private_key
Reads a PKCS#8, PKCS#1, or SEC1 PEM private key.
load_roots
Reads PEM certificates to trust, for a caller pinning its own authority.
rotating_quic_server_config
A rustls server configuration for QUIC, with the same rotating certificate as TlsListener.
rotating_tcp_server_config
A rustls server configuration for TCP, with a rotating certificate.