[tls]
tls.client
Settings for every outbound TLS (encrypted) connection: HTTP calls, mail, LDAP, databases and the shared cache (Core\Cache::shared()).
roots is the list of trusted certificate authorities (CAs). When it is not set, Novis uses the Mozilla set that ships with it. You can add your own CA to that set, or list only your own files. A database, LDAP, mail or IMAP block can set its own tls_ca_file. That block then trusts only that file. It does not use roots. min_version is the lowest TLS version allowed, 1.2 or 1.3. The default is 1.2. keylog names a file where Novis writes the keys that encrypt each connection. A tool such as Wireshark can then read your own traffic. keylog is not allowed when [mode] default is production.
A program cannot change these settings.
If a TLS connection fails, the error names the cause and the fix (TLS connections).
Good to know: a running server applies a change when you save nvs.toml. If a file in roots contains no certificate, the old settings stay in use. The server writes a warning to its log.
Only nvs.toml sets this key. A request may not change it.
A change in the file takes effect a few seconds after you save it. The server does not restart.
The examples below run with this configuration file.
# Every outbound TLS connection uses TLS 1.2 or newer.[tls.client]min_version = "1.2"Which certificates outbound connections trust
<?nvs// `[tls.client]` configures every outbound TLS connection: HTTP calls, mail, LDAP, databases and// the shared cache. It sets the trusted certificates, the lowest TLS version and a key log file.// This file sets the lowest version to `1.2` and does not set the other two.
echo 'oldest version: ', Core\Config::get('tls.client.min_version') ?? '(no value)', "\n";echo 'secrets written: ', Core\Config::get('tls.client.keylog') ?? '(nothing, so none)', "\n";
// `roots` is a list. `Core\Config::get` cannot read a list, so it returns `null`. Without `roots`, Novis trusts its// built-in certificate authorities. `roots = ["bundled", "/etc/novis/corp-ca.pem"]` adds one more.echo 'trust anchors: ', Core\Config::get('tls.client.roots') ?? '(a list: the shipped set)', "\n";
// A program cannot change these three settings. With the key written in the call, the program// does not compile. Here the keys are in variables, so `Core\Config::set` runs and returns `false`.string $roots = 'tls.client.roots';string $minVersion = 'tls.client.min_version';string $keylog = 'tls.client.keylog';echo 'trust one more: ', Core\Config::set($roots, '["/tmp/mine.pem"]') ? 'yes' : 'no', "\n";echo 'speak older TLS: ', Core\Config::set($minVersion, '1.2') ? 'yes' : 'no', "\n";echo 'write secrets: ', Core\Config::set($keylog, '/tmp/keys.log') ? 'yes' : 'no', "\n";
// The failed calls changed nothing, so the oldest version is still `1.2`.echo 'still in force: ', Core\Config::get('tls.client.min_version') ?? '(nothing)', "\n";oldest version: 1.2secrets written: (nothing, so none)trust anchors: (a list: the shipped set)trust one more: nospeak older TLS: nowrite secrets: nostill in force: 1.2Changelog
| Version | Change |
|---|---|
0.0.6 | A failed TLS connection names its cause, who can fix it and how, as TLS connection errors explains. For an expired certificate, the message gives the date it expired and the time on this host's clock. For a wrong pin, it gives the sha256// hash of the server's public key. |
0.0.6 | The [http.client.tls] block is now [tls.client]. Its keys set the trusted certificates and the lowest TLS version of every outbound connection: HTTP, mail, LDAP, databases and the shared cache. When a certificate is not trusted, the error names the setting that fixes it. |
