Stalwart’s built-in ACME works well for us: per-domain certificates via TLS-ALPN-01 and automatic renewal, with
no extra moving parts. The problem starts when the same host name is also served by another TLS service on the
same machine, e.g. an admin panel such as Webmin on :10000, a reverse proxy, or another daemon. Those services
need the same certificate. In our experience, browsers handle one host name that presents different certificates
on different ports badly: the page fails to load or hangs, not the usual click-through warning.
Today there is no way to share the certificate:
- Certificate.privateKey is a SecretText. The API always returns “****” for it (the generated
IntoValue for SecretTextValue), and snapshots omit it. Good default security, but it means there is no
supported path to the key, not even for an administrator on the host. - So the only way to share one certificate is to stop using Stalwart’s ACME, run certbot, and import the result.
0.16 makes that possible (Certificate.certificate/privateKey accept the File variant, plus the
ReloadTlsCertificates action - thank you). But it turns the dependency around: the integrated, more robust
ACME client is the one we can’t use, and an external one plus a deploy hook becomes critical for mail.
Either of these would solve it:
- Export on issuance/renewal: an option on the ACME provider or the managed certificate to write the chain and
key to a directory after every issuance and renewal (e.g. //fullchain.pem and privkey.pem, key
mode 0600, owner configurable). Other services read the files, as they do with certbot’s
/etc/letsencrypt/live/. - A post-renewal hook: a configured command run after a certificate is issued or renewed (or a webhook event
carrying the certificate ID), plus an administrator-only way to read the key on the host (e.g. a CLI command,
or a permission that allows an unmasked read).
Option 1 would make the file interface two-way: 0.16 already imports from files, and this would export to them.
Not every deployment runs Stalwart alone in a container on a dedicated address. On a normal server, sharing
certificates between services on the same name is routine, and certbot (deploy hooks), Caddy and Traefik all
offer some form of it.
Related: discussion #1112 (2025-01, asked how to get ACME certificates out for other software), #3222 (import
direction, closed as not planned), and my earlier GitHub issue on this, closed during the move to the forum: