certbot certificates shows the new date, but browsers still get the old certificate. nginx, Apache, Postfix
and Dovecot read the certificate when they start and keep it in memory until they reload.
Confirm it
sudo certbot certificates | grep -E 'Name|Expiry'
echo | openssl s_client -connect example.com:443 -servername example.com 2>/dev/null \
| openssl x509 -noout -enddate
If the dates differ, the file is new and the server is serving the old one. sudo systemctl reload nginx fixes it now.
A deploy hook fixes it for every renewal after this one.
Add a deploy hook
Certbot runs every executable file in /etc/letsencrypt/renewal-hooks/deploy/ after a successful renewal:
sudo tee /etc/letsencrypt/renewal-hooks/deploy/reload.sh >/dev/null <<'EOF'
#!/bin/sh
# reload whatever is installed and running
for s in nginx apache2 httpd postfix dovecot; do
systemctl is-active --quiet "$s" && systemctl reload "$s"
done
exit 0
EOF
sudo chmod +x /etc/letsencrypt/renewal-hooks/deploy/reload.sh
The hook runs once per renewed certificate. $RENEWED_LINEAGE holds its folder, for example
/etc/letsencrypt/live/example.com, and $RENEWED_DOMAINS its names.
HAProxy and other servers that want one file
HAProxy reads the certificate and key from one PEM file. Build it in the hook, then reload:
cat "$RENEWED_LINEAGE/fullchain.pem" "$RENEWED_LINEAGE/privkey.pem" \
> /etc/haproxy/certs/example.com.pem
systemctl reload haproxy
A hook for one certificate only
Put it in that certificate's renewal file, /etc/letsencrypt/renewal/example.com.conf, under
[renewalparams]:
renew_hook = systemctl reload postfix
Test the hook
certbot renew --dry-run skips deploy hooks, so run the script yourself:
sudo RENEWED_LINEAGE=/etc/letsencrypt/live/example.com \
/etc/letsencrypt/renewal-hooks/deploy/reload.sh
Then compare the dates again. On a mail server, check each port: checking a mail server's certificate.