Karta. SMTP. TLSConfig
(Karta v1.0.0)
Server-side TLS settings for the SMTP listeners, with certificate hot reload.
- Protocols: TLS 1.3 and TLS 1.2 only.
- TLS 1.2 suites: ECDHE key exchange (forward secrecy) with AEAD ciphers (AES-GCM, ChaCha20-Poly1305) only. No static RSA or static ECDH key exchange, no CBC, no SHA-1 MACs.
- No client-initiated renegotiation.
Certificates are read from PEM files and handed to :ssl as DER, so :ssl's
own PEM file cache never serves a stale certificate. The files are re-read
every reload_interval milliseconds; when their content changed and the new
pair is valid (it parses and the key matches the certificate), new
handshakes use it. An invalid new pair is logged and the previous one stays
in use. Listeners fetch server_options/1 at every handshake, so a reload
never restarts a listener or drops a connection.
Summary
Functions
The protocol and cipher settings, without certificates.
Returns a specification to start this module under a supervisor.
TLS 1.3 AEAD suites, then TLS 1.2 ECDHE suites with AEAD ciphers.
Re-reads the certificate files now. Returns :ok or the reason the new files were refused.
The :ssl server options for a new handshake.
Options: name (default Karta.SMTP.TLSConfig), certificates (a
non-empty list of %{certfile: path, keyfile: path}; one RSA and one ECDSA
pair is a good choice) and reload_interval in milliseconds (default
60 000). Fails to start when the initial files are missing or invalid.
Types
Functions
@spec base_options() :: [:ssl.tls_server_option()]
The protocol and cipher settings, without certificates.
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec ciphers() :: [:ssl.erl_cipher_suite()]
TLS 1.3 AEAD suites, then TLS 1.2 ECDHE suites with AEAD ciphers.
@spec reload(GenServer.server()) :: :ok | {:error, term()}
Re-reads the certificate files now. Returns :ok or the reason the new files were refused.
@spec server_options(GenServer.server()) :: [:ssl.tls_server_option()]
The :ssl server options for a new handshake.
Options: name (default Karta.SMTP.TLSConfig), certificates (a
non-empty list of %{certfile: path, keyfile: path}; one RSA and one ECDSA
pair is a good choice) and reload_interval in milliseconds (default
60 000). Fails to start when the initial files are missing or invalid.