Module security
Expand description
Authentication and TLS for every connection: workers and clients to a server, and replicas to each other.
Two independent layers wrap the socket before its first protocol frame:
- TLS 1.3 (rustls with the ring provider). A listener presents its certificate. A listener that also has a CA requires the connecting side to present a certificate signed by it (mutual TLS). A connecting side verifies the listener’s certificate against its CA and the host name or IP address it dialled. Replicas always use mutual TLS.
- A shared-secret token, proven with an HMAC-SHA256 challenge and response over both sides’ fresh nonces, in both directions. The secret never crosses the wire, and under TLS the proofs are bound to the session, so they cannot be relayed into another connection. A Unix socket or loopback deployment can authenticate without certificates.
Without either, the socket carries the plain protocol. Both layers are stream wrappers: the server and the replicas see a stream that reads and writes plaintext, and never the handshake.
A token without TLS authenticates the start of each connection only. An attacker on the network path can still read the traffic and inject into an authenticated TCP stream; use TLS wherever the network is not trusted.
Structs§
- Security
- Security settings for one side of a connection.
- Tls
- Certificates for TLS 1.3: this side’s chain and key, and the CA that signs the other side’s certificate.
- Token
- A shared secret both sides prove they hold. Its bytes are never printed.
Enums§
- Scope
- What a server-protocol token may do. The listener’s own token
(
Security::token) is a worker’s; others are added withServer::set_security_scoped. A connecting side proves its token as with a single one: the listener finds which one it holds.