Skip to main content

Module tls

Module tls 

Source
Expand description

Shared TLS materials and HTTPS serving helpers for HTTP services.

Provides:

  • TlsMaterials: DER-encoded cert + key pair
  • get_or_init_tls_materials(): OnceLock-based lazy generation (self-signed or file-loaded)
  • resolve_rustls_config(): Resolves per-service or shared TLS config
  • serve_app(): Serves an Axum router over HTTPS or HTTP with graceful shutdown

TLS modes (set via [tls] mode):

  • self-signed (default) — rcgen-generated, dev/air-gapped only
  • acme — automatic via RFC 8555 (Let’s Encrypt or self-hosted step-ca / Pebble)
  • files — operator-supplied PEM paths

Structs§

ResolvedTlsConfig
Resolve the rustls configuration for a service.
TlsMaterials
DER-encoded TLS certificate and private key.

Enums§

BoundHttpListener
A bound HTTP(S) listener retained between the bind and serve phases.

Functions§

bind_listener
Bind phase: a real std::net::TcpListener::bind plus set_nonblocking.
get_or_init_tls_materials
Get or initialize the shared TLS materials.
resolve_rustls_config
Resolve HTTP TLS configuration and any protocol-specific acceptor.
serve_app
Serve an Axum router over HTTPS (if rustls_config is Some) or plain HTTP.
serve_bound
Serve phase: consume a BoundHttpListener with graceful shutdown.