Skip to content

TLS Certificates

Every nzyme-node serves its web interface and REST API over HTTPS only. Taps report to the same HTTPS listener. A node generates a self-signed certificate when it starts for the first time, and you can replace it with a certificate of your own at any time.

You can find all certificates under System -> Keys & Certificates in your Nzyme web interface. The page is available to super administrators only.

Certificate Sources

A node can get its certificate from three sources. It uses the first one in this order that exists:

Order Source How it is configured Applies to
1 Local disk Two files in the crypto directory of the node. The node that has the files.
2 Wildcard certificate Uploaded in the web interface together with a regular expression for node names. Every node with a matching name.
3 Individual certificate Uploaded in the web interface for one node, or generated by the node itself. The node it was uploaded for.

Certificates and keys that are uploaded in the web interface are stored encrypted in the database.

Certificate and Key Format

Certificate and key are two separate files in PEM format, both in the web interface and on disk.

File Requirements
Certificate One or more -----BEGIN CERTIFICATE----- blocks. The certificate of the node comes first, followed by the intermediate certificates of the chain.
Private key An RSA or ECDSA key in PKCS#8 format (-----BEGIN PRIVATE KEY-----) or in the traditional format (-----BEGIN RSA PRIVATE KEY-----, -----BEGIN EC PRIVATE KEY-----), without a passphrase.

Ed25519 keys are not supported.

Loading a Certificate from Disk

A certificate on the disk of a node always takes precedence over wildcard and individual certificates. This is the right source for certificates that are renewed automatically, for example by an ACME client, and for nodes that are set up by configuration management.

Place the two files in the crypto directory of the node. This is the crypto_directory of your nzyme.conf and /usr/share/nzyme/crypto by default.

File Content Required permissions
tls.cert The certificate chain in PEM format. Readable by the user that runs nzyme-node.
tls.key The private key in PEM format. Mode 600 and owned by the user that runs nzyme-node.

The crypto directory itself must not be accessible by other users (mode 700). The Nzyme packages run nzyme-node as the user nzyme:

sudo install -o nzyme -g nzyme -m 600 privkey.pem /usr/share/nzyme/crypto/tls.key
sudo install -o nzyme -g nzyme -m 644 fullchain.pem /usr/share/nzyme/crypto/tls.cert

Both files must exist. A node with only one of them ignores it.

The node stores a copy of a certificate it loaded from disk in the database. The web interface lists it as Individual, initially loaded from file. If you remove the files later, the node keeps using this copy unless a wildcard certificate matches the node.

Automatic Reload

A running node checks the two files once per minute. When the certificate in tls.cert is not the one in use, the node restarts its HTTPS listener with the certificate and key from disk. You do not have to restart nzyme-node after a renewal, and a renewal tool only has to write the two files.

  • The restart of the listener closes open connections for a moment.
  • The node compares the first certificate in tls.cert with the one in use. A file in which only the intermediate certificates or only the key changed is loaded with the next restart of nzyme-node.
  • In a setup with multiple nodes, every node watches its own crypto directory.

Certificates That Are Not Loaded

A running node does not load a certificate from disk in the following cases. It keeps the certificate in use, writes a warning with the reason to its log and tries again with the next check.

Reason What to do
A file cannot be read or is not valid PEM. Check the files and their owner.
The key does not belong to the certificate. Nothing if the two files are just being replaced one after the other. The next check loads them. Otherwise write the key that belongs to the certificate.
The file permissions are ones the node would refuse to start with. Run the chmod commands from the log message. The check covers the crypto directory, tls.key, the PGP private key and the configuration file of the node.

The same checks apply when a change of a certificate in the web interface makes a node reload its certificate.

Warning

A node refuses to start if tls.key or the crypto directory can be accessed by other users. A key that a renewal tool writes with open permissions is not loaded for the same reason, and the old certificate stays in use until you fix the permissions. Make sure that your renewal tool writes tls.key with mode 600.

Wildcard Certificates

A wildcard certificate is uploaded once and used by every node whose name matches its node matcher, a regular expression. The upload form can test which of your nodes match before you save. This is the easiest way to provision many nodes that share a domain. Wildcard certificates take precedence over individual certificates.

Matching nodes load a new, replaced or deleted wildcard certificate without a restart.

Individual Certificates

The details page of a node under TLS Certificates in Use lets you upload a certificate and key for that node. The node loads it without a restart, unless a certificate on its disk or a wildcard certificate takes precedence.

The same page can replace the current certificate with a new self-signed certificate that is valid for 12 months.

Self-Signed Certificates and Taps

Taps do not trust a self-signed certificate. A tap that reports to a node with one needs accept_insecure_certs = true in the general section of its configuration. Set it to false once the node has a certificate from a certificate authority that the tap host trusts.

Health Indicators

Two indicators of the system health console are about certificates and their files. Like every other indicator they generate system events that you can subscribe to.

Indicator Red when
TLS Expiration A wildcard certificate or the certificate of a node expires within seven days.
Node File Permissions A running node finds insecure permissions on its crypto directory, key files or configuration file.

A certificate on disk that is not loaded leaves the old certificate in use, so the TLS Expiration indicator also warns you when a renewal did not arrive.