Module tls

Module tls 

Source
Expand description

TLS transport for the HTTP API.

bindcar’s REST API carries a privileged bearer credential on every request — a Kubernetes ServiceAccount token under TokenReview auth, or the shared BIND_API_TOKEN. Authentication proves who the caller is; it does nothing for confidentiality. Without TLS that credential crosses the pod network in the clear, readable by anything able to observe the link.

This module resolves the TLS configuration and builds the [rustls] server config. TLS is opt-in: with no certificate configured bindcar serves plaintext exactly as before, so existing deployments are unaffected.

§Configuration

CLI flagEnvironment variableMeaning
--tls-certBIND_TLS_CERTPEM certificate chain, leaf first
--tls-keyBIND_TLS_KEYPEM private key (PKCS#8, PKCS#1 or SEC1)
--tls-client-caBIND_TLS_CLIENT_CAPEM CA bundle; presence turns on mTLS

§Fail-closed rules

Misconfiguration is a startup error, never a silent downgrade:

  • Exactly one of cert/key set → TlsError::IncompleteKeyPair. Falling back to plaintext here would serve the API in the clear on a deployment whose operator believes TLS is on.
  • A client CA with no key pair → TlsError::ClientCaWithoutTls, rather than accepting the flag and ignoring it.
  • Unreadable or unparseable PEM → an error before the listener binds.

Structs§

TlsReloader
Holds the live [rustls::ServerConfig] and swaps it when the files change.
TlsSettings
A resolved, syntactically valid TLS configuration.

Enums§

TlsError
Errors raised while resolving or loading the TLS transport configuration.

Constants§

DEFAULT_RELOAD_INTERVAL_SECS
How often the certificate files are re-examined, in seconds.

Functions§

build_server_config
Build the [rustls::ServerConfig] for the API listener.
ensure_crypto_provider
Install the process-wide rustls crypto provider (aws-lc-rs).
fingerprint
Fingerprint the TLS material currently on disk.
resolve_tls_settings
Resolve TLS settings from the certificate, key and client-CA options.
scheme_for
The URL scheme bindcar serves under, for log lines and the advertised docs URL.