The SSL cert that expired on a Sunday
Sunday morning, the site served a certificate that had expired three hours earlier. Auto-renewal had been running, but it renewed a different domain variant while nginx pointed at an old certificate path. Seven checks: the live certificate, what certbot manages, renewal conf domains, timer status, dry-run, deploy hooks, and a 14-day expiry alert.
📜 Table of Contents
📖 Keep reading
The SSL cert that expired on a Sunday
Sunday morning, coffee in hand, the browser answered with a full page of red: your connection is not private. The certificate had expired three hours earlier.
Fixed in fifteen minutes. But the site had live landing pages, and search traffic does not wait.
The postmortem found two deviations stacked: certbot's renewal config covered a different domain variant, and nginx pointed at a hand-edited path to an older certificate file. Both sides were "correct" and the site was down.

1. Look at the certificate actually served
Do not inspect /etc/letsencrypt/live/ first. Ask the server:
openssl s_client -connect example.com:443 -servername example.com </dev/null 2>/dev/null \
| openssl x509 -noout -subject -issuer -dates
notAfter is the real expiry; the SAN list is the real coverage. Always pass -servername, or SNI is missing and you may get the default server block's certificate.
2. Then what certbot thinks it manages
certbot certificates
Compare domains and expiry against step 1. In my case certbot reported a certificate valid until January while the server served one that expired that morning.
3. Seven checks
| Check | Command | Pass condition |
|---|---|---|
| live certificate | openssl s_client -servername |
dates and SANs correct |
| managed certs | certbot certificates |
matches step 1 |
| renewal domains | grep -r domains /etc/letsencrypt/renewal/ |
all variants listed |
| timer alive | systemctl list-timers \| grep certbot |
has a next run |
| renewal possible | certbot renew --dry-run |
all success |
| nginx paths | nginx -T \| grep ssl_certificate |
points at live/, not archive/ |
| port 80 reachable | curl -I http://example.com/.well-known/acme-challenge/test |
not redirected away |
That last row matters: a blanket https redirect that also captures the ACME challenge path will break renewal silently.
4. Deploy hooks: renewed is not served
certbot writes new files under /etc/letsencrypt/live/<domain>/; nginx keeps the old certificate until reloaded.
certbot renew --deploy-hook "systemctl reload nginx"
Use reload, not restart. With the nginx plugin certbot reloads itself; with webroot or standalone you must add the hook.
5. Alert 14 days early
#!/usr/bin/env bash
DOMAIN="example.com"; WARN_DAYS=14
end=$(openssl s_client -connect "$DOMAIN:443" -servername "$DOMAIN" </dev/null 2>/dev/null \
| openssl x509 -noout -enddate | cut -d= -f2)
days=$(( ($(date -d "$end" +%s) - $(date +%s)) / 86400 ))
[ "$days" -lt "$WARN_DAYS" ] && \
echo "cert expires in $days days ($end)" | mail -s "[alert] SSL expiry" ops@example.com
Monitor the certificate the server returns, not the files on disk. That was the one thing I lacked.
6. Emergency three commands
certbot renew --force-renewal --cert-name example.com
nginx -T | grep ssl_certificate
nginx -s reload
Then re-verify with openssl s_client. Keep --force-renewal out of cron; rate limits are weekly and unforgiving.
7. After an outage
- HSTS: browsers that saw the header will keep refusing plain http until max-age expires
- API clients: restart anything that caches the chain
- CDN: fix origin first, then purge edge certificates
FAQ
Renewed but still the old certificate? Usually no reload, or a hardcoded archive/ path. Check nginx -T.
Separate certs for www and apex? One certificate can hold both, but both hosts must resolve here and pass validation.
Does --dry-run consume issuance quota? No, it uses staging. It does make real validation requests, so it catches port and path problems.
Why Sundays? certbot timers use random delays and often land on weekend nights, when nobody is watching. Monitoring beats automation.
certbot flags and Let's Encrypt rate limits change; check their official docs.
Related
Written by our editorial team; tools listed here are tested or verified against public sources. Links point to official sites or GitHub repos for reference only — no paid placements.