cert-reload: renew Postfix's copy of a renewed certificate (audit H2)

postfix-config.sh copies the mounted certificate and key into
/etc/postfix/tls-internal at start (root-owned, key 0600) and Postfix reads
the copy; cert-reload only ran `postfix reload` daily, which re-read the
stale copy, so a certificate renewed while the container ran expired on
465/587 with the old one.

postfix-cert-reload.sh now, every TLS_RELOAD_INTERVAL_SECONDS: compares the
mount with the copy (cmp); when they differ and the certificate and key
belong together (openssl public keys equal - a renewer writes them one
after the other), writes each file beside its target, root-owned with the
start's modes, renames it over the target, and reloads Postfix. Nothing
changed - no reload. No copy (files missing at start) - the old periodic
reload. Never exits non-zero.

e2e renewed_certificate_picked_up: writes a new certificate into the
stand's mount and waits (30 s) for port 465 to present its serial;
compose.override.yml sets TLS_RELOAD_INTERVAL_SECONDS=2.
supervisord.conf comment, architecture.md (process table, § Postfix TLS
certs, the env knob), guide (after the proxies: picked up within a day).
CHANGELOG [Unreleased], audit plan line ticked, roadmap 12/61.

Evidence: GOOS=linux go vet in test/e2e clean; the server run of the stage
follows before the push.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
mix
2026-10-14 14:25:20 +03:00
co-authored by Claude Opus 5.5
parent 63520f1678
commit 7af37654a1
10 changed files with 179 additions and 26 deletions
+4
View File
@@ -48,6 +48,10 @@ services:
# loops well past this count) is meant to hit it.
RATE_LIMIT_MESSAGES_PER_IP: "50"
RATE_LIMIT_WINDOW_SECONDS: "60"
# cert-reload compares the mounted certificate with Postfix's copy this
# often, so renewed_certificate_picked_up does not wait a day. It
# reloads Postfix only when the certificate changed.
TLS_RELOAD_INTERVAL_SECONDS: "2"
ports: !override
- "20465:465"
- "20587:587"