Securing database connections with TLS / mTLS
The KMS supports TLS-encrypted connections and mutual TLS (mTLS) client-certificate authentication
for PostgreSQL and MySQL-compatible databases. All TLS parameters are configured directly in the
database-url as query parameters — no extra CLI flags or TOML keys are needed.
PostgreSQL TLS / mTLS
PostgreSQL TLS is configured using the standard libpq-style query parameters in the connection URL.
| Parameter | Description |
|---|---|
sslmode | TLS mode: disable, allow, prefer (default), require, verify-ca, verify-full |
sslrootcert | Path to the CA certificate (PEM) used to verify the server |
sslcert | Path to the client certificate (PEM) for mTLS |
sslkey | Path to the client private key (PEM) for mTLS |
Server-authenticated TLS only (encrypt the connection and verify the server certificate):
[db]
database_type = "postgresql"
database_url = "postgres://kms:kms@pgsql-server:5432/kms?sslmode=verify-ca&sslrootcert=/path/to/ca.crt"
Mutual TLS (mTLS) (encrypt + verify server certificate + present a client certificate):
[db]
database_type = "postgresql"
database_url = "postgres://kms:kms@pgsql-server:5432/kms?sslmode=verify-full&sslrootcert=/path/to/ca.crt&sslcert=/path/to/client.crt&sslkey=/path/to/client.key"
disable– no TLS at all.allow/prefer(default) – TLS is used if the server offers it, otherwise the connection silently falls back to plaintext. The server certificate is not verified.require– the connection fails if the server does not support TLS. The server certificate is not verified, unlesssslrootcertis also set, in which case it is verified against that CA (the hostname is still not checked).verify-ca– the server certificate is verified against thesslrootcertCA but the hostname is not checked.sslrootcertis mandatory: as withlibpq, the KMS refuses to start withverify-caand nosslrootcert.verify-full– the server certificate is verified against the CA and the hostname must match. This is the recommended mode for production.
Any other sslmode value is rejected at startup. When sslrootcert is set, only that CA is
trusted (the system CA store is not consulted); verify-full without sslrootcert verifies
against the system CA store. All certificates must be in PEM format.
MySQL / MariaDB TLS / mTLS
MySQL TLS is configured using query parameters in the connection URL.
Both dash (ssl-mode) and underscore (ssl_mode) variants are accepted.
| Parameter | Description |
|---|---|
ssl-mode | TLS mode: DISABLED, PREFERRED, REQUIRED, VERIFY_CA, VERIFY_IDENTITY |
ssl-ca | Path to the CA certificate (PEM) for server verification |
ssl-client-identity | Path to the client PKCS#12 (.p12) bundle for mTLS |
ssl-client-identity-password | Password protecting the PKCS#12 bundle |
Server-authenticated TLS only (encrypt the connection and verify the server certificate):
[db]
database_type = "mysql"
database_url = "mysql://kms:kms@mysql-server:3306/kms?ssl-mode=VERIFY_CA&ssl-ca=/path/to/ca.crt"
Mutual TLS (mTLS) (encrypt + verify server certificate + present a client certificate):
[db]
database_type = "mysql"
database_url = "mysql://kms:kms@mysql-server:3306/kms?ssl-mode=VERIFY_CA&ssl-ca=/path/to/ca.crt&ssl-client-identity=/path/to/client.p12&ssl-client-identity-password=secret"
DISABLED– no TLS at all.PREFERRED/REQUIRED– TLS is used but the server certificate is not verified.VERIFY_CA– the server certificate is verified against the CA. Whenssl-cais set, only that CA is trusted (the system CA store is not consulted); the file must contain the root CA of the server chain. Withoutssl-ca, the system CA store is used.VERIFY_IDENTITY– the server certificate is verified against the CA and the hostname must match.
MySQL client-certificate authentication requires the certificate and private key bundled as a
PKCS#12 (.p12) file — PEM files are not supported.
You can create the bundle using OpenSSL:
openssl pkcs12 -export \
-in client.crt -inkey client.key \
-out client.p12 -passout pass:secret
PKCS#12 client identity (ssl-client-identity) is not available in FIPS mode.
MySQL mTLS with client certificates requires the non-fips feature.