Zero-Downtime TLS Certificate Rotation Patterns for Edge Proxies

· Daniel Lin tlsnginxsecurityops

Short-lived certificates (90 days today, and trending shorter across public CAs) make manual renewals unacceptable. Yet automated renewal is only half the story: reloading a live TLS terminator under active long-lived connections has subtle failure modes if you are not careful.

Why SIGHUP Can Still Hurt Long-Lived Streams

With Nginx, nginx -s reload spawns new worker processes with the freshly minted PEM chain while older workers drain existing TCP sockets. On HTTP/1.1 this finishes in seconds. On long-lived HTTP/2 or WebSocket streams, old workers can linger for hours, temporarily doubling memory usage if multiple reloads overlap.

Patterns That Hold Up Under Load

  1. Atomic file swaps only: never write directly over fullchain.pem. Write to a temporary file on the same filesystem and call rename(2) so readers never observe a half-written certificate or mismatched cert/key pair.
  2. File-watcher hot reload where supported: modern Go and Rust TLS listeners can load certificates lazily via GetCertificate callbacks or atomic ArcSwap pointers, serving the new chain to every subsequent ClientHello without dropping or duplicating worker processes.
  3. Separate renewal checks from reload storms: renew when remaining validity drops below 30 days, verify the chain with openssl x509 -noout -dates, and alert independently if any live endpoint reports fewer than 14 days remaining.
# Quick verification of live chain expiry from CI or monitoring
echo | openssl s_client -servername example.com -connect example.com:443 2>/dev/null   | openssl x509 -noout -subject -issuer -dates
← Debugging Tail Latency Spikes in Multi-Region PostgreSQL 17 ReplicasPractical eBPF Socket Tracing Without Kernel Module Headaches →