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§
- Certificate
Resolver - Answers every handshake from a slot that can be replaced underneath it.
- Certificate
Watch - Keeps the debouncer and its pump alive for as long as its owner lives.
- Client
Identity - A client certificate and key that reload underneath a running caller.
- Ignore
TlsEvents - 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.