certbot is the dominant ACME client because it ships in every distro repo and gets the boring 95 % right out of the box. This article is the operator’s version of the quick-start: not just “issue a cert”, but how the renewal timer actually works, how to wire deploy hooks so the right daemon reloads, and how to keep one bad domain from burning the weekly rate limit for the whole environment.
How to verify
Inspect what certbot believes it manages and when each cert renews:
sudo certbot certificates
sudo systemctl list-timers --all | grep certbot
sudo certbot renew --dry-run
sudo journalctl -u certbot.timer --since "30 days ago"
openssl x509 -in /etc/letsencrypt/live/<domain>/cert.pem -noout -dates -subject
certbot certificates prints expiry, key type, and SANs for every managed certificate. The dry run executes the full renewal flow against the staging API without consuming production rate limits.
What’s happening
Let’s Encrypt issues 90-day certificates over the ACME protocol. certbot performs the ACME dance — register an account, request authorisations for each domain, respond to a challenge, download the issued cert — then writes everything under /etc/letsencrypt/. A renewal config lives at /etc/letsencrypt/renewal/<domain>.conf and tells certbot exactly how to re-run that flow without operator input.
The HTTP-01 challenge requires that the ACME server reach http://<domain>/.well-known/acme-challenge/<token> from the public internet and read back a known string. certbot’s --nginx and --apache plugins edit the web server config to serve that file; the --webroot plugin instead drops the file into a known directory. The DNS-01 challenge — covered in the wildcard article — proves control by writing a TXT record. The certbot.timer systemd unit runs certbot renew twice a day; the renewal command does nothing for certs that are more than 30 days from expiry, so the timer is safe to run frequently.
The procedure
- Install certbot from the distro packages, not pip.
sudo apt install certbot python3-certbot-nginx(orpython3-certbot-apache). The plugin matters — it’s how certbot updates the web server config and reloads it. - Issue the first certificate with
--nginxor--apachefor a turnkey path.sudo certbot --nginx -d www.example.com -d example.com --email ops@example.com --agree-tos --no-eff-email. The--no-eff-emailflag suppresses the EFF subscription prompt that breaks automation. - Validate the renewal config.
sudo cat /etc/letsencrypt/renewal/www.example.com.conf— confirmauthenticator = nginx, theinstallerline, and the list of domains. This file is whatcertbot renewreads months later. - Wire a deploy hook for daemons certbot does not know about.
sudo mkdir -p /etc/letsencrypt/renewal-hooks/deploy && sudo tee /etc/letsencrypt/renewal-hooks/deploy/reload.sh <<'EOF'\n#!/bin/sh\nset -e\nsystemctl reload haproxy\nsystemctl restart postfix\nEOF\nsudo chmod +x /etc/letsencrypt/renewal-hooks/deploy/reload.sh. Hooks run only after a successful renewal. - Run the dry run against staging at least once.
sudo certbot renew --dry-run. Failures here are the difference between a routine renewal and a Saturday-morning outage. - Confirm the timer is enabled.
sudo systemctl enable --now certbot.timer && sudo systemctl status certbot.timer. On Debian/Ubuntu the systemd timer ships pre-enabled; on RHEL family you may need to enable it explicitly. - Forward
journalctl -u certbotlines into your log aggregator and alert onnon-zerorenewal exits. A cert that fails to renew for 14 days is silent until the day the page goes red.
Common pitfalls
- The Let’s Encrypt rate limit is 50 certificates per registered domain per week. A loop that re-issues on every deploy can burn that limit in minutes. Cache the cert and re-use it.
- Renaming a domain creates a new cert and a new renewal config — the old one keeps trying to renew for a vanished name and fills the log with errors. Remove it with
sudo certbot delete --cert-name <old-name>. - The
--nginxplugin rewritesserver { listen 80; }blocks in place. If you template Nginx config from Ansible or similar, the plugin’s edits get clobbered on the next deploy. Use--webrootwith templated config instead. - Deploy hooks run as root with no shell —
set -eand absolute paths are mandatory. - A cert with
RSA 2048and one withECDSA P-256are stored under differentlive/directories on some distros if you re-issue with--key-type ecdsa. Nginx will keep serving the old key until the config is updated.
In the engagements we run, TLS issuance is treated as critical infrastructure: monitored, alerted on, and exercised against staging before any change touches production. That posture is part of Managed Operations, and it is why a Stack Harbor client rarely learns about an expired cert from a customer.