Certbot ist das offizielle Tool zum Verwalten von Let's Encrypt-Zertifikaten. Es automatisiert Erstellung und Erneuerung.
Certbot installieren
Ubuntu/Debian
apt update
apt install certbotMit Apache-Plugin
apt install python3-certbot-apacheMit Nginx-Plugin
apt install python3-certbot-nginxCentOS/AlmaLinux
dnf install certbot python3-certbot-nginxZertifikat für Apache
Automatisch (empfohlen)
certbot --apache -d example.com -d www.example.comCertbot: 1. Verifiziert Domain-Besitz 2. Erstellt Zertifikat 3. Konfiguriert Apache 4. Aktiviert HTTPS
Nur Zertifikat (manuell konfigurieren)
certbot certonly --apache -d example.comZertifikat für Nginx
Automatisch
certbot --nginx -d example.com -d www.example.comNur Zertifikat
certbot certonly --nginx -d example.comStandalone-Modus
Wenn kein Webserver läuft:
certbot certonly --standalone -d example.comWichtig: Port 80 muss frei sein.
Webroot-Modus
Für komplexere Setups:
certbot certonly --webroot -w /var/www/html -d example.comCertbot legt eine Datei in .well-known/acme-challenge/ ab.
Nginx-Konfiguration für Webroot
location /.well-known/acme-challenge/ {
root /var/www/certbot;
}Zertifikate anzeigen
certbot certificatesAusgabe:
Certificate Name: example.com
Domains: example.com www.example.com
Expiry Date: 2024-04-20
Certificate Path: /etc/letsencrypt/live/example.com/fullchain.pem
Private Key Path: /etc/letsencrypt/live/example.com/privkey.pemZertifikatsdateien
Nach Erstellung unter /etc/letsencrypt/live/example.com/:
| Datei | Beschreibung | |-------|--------------| | cert.pem | Zertifikat | | chain.pem | Intermediate-Zertifikat | | fullchain.pem | Zertifikat + Chain | | privkey.pem | Privater Schlüssel |
Nginx-Konfiguration
server {
listen 443 ssl http2;
server_name example.com;
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
}Apache-Konfiguration
<VirtualHost *:443>
ServerName example.com
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
</VirtualHost>Automatische Erneuerung
Let's Encrypt-Zertifikate sind 90 Tage gültig. Certbot erneuert automatisch.
Timer prüfen
systemctl status certbot.timerManuell testen
certbot renew --dry-runCronjob (falls kein systemd)
crontab -e0 3 * * * certbot renew --quietHooks bei Erneuerung
Webserver neu laden
Bei /etc/letsencrypt/renewal/example.com.conf:
[renewalparams]
# ...
post_hook = systemctl reload nginxMit Befehlszeile
certbot renew --post-hook "systemctl reload nginx"Deploy-Hook (nur bei Erneuerung)
certbot renew --deploy-hook "systemctl reload nginx"Wildcard-Zertifikate
Für *.example.com:
certbot certonly --manual --preferred-challenges dns -d "*.example.com" -d example.comSie müssen einen TXT-Record bei Ihrem DNS-Provider setzen.
Mit DNS-Plugin (automatisch)
Für Cloudflare:
apt install python3-certbot-dns-cloudflareCredentials in /etc/letsencrypt/cloudflare.ini:
dns_cloudflare_api_token = DEIN_TOKENchmod 600 /etc/letsencrypt/cloudflare.ini
certbot certonly \
--dns-cloudflare \
--dns-cloudflare-credentials /etc/letsencrypt/cloudflare.ini \
-d "*.example.com" -d example.comMehrere Domains
Im selben Zertifikat
certbot --nginx -d example.com -d www.example.com -d mail.example.comSeparate Zertifikate
certbot --nginx -d example.com
certbot --nginx -d andere-domain.deZertifikat löschen
certbot delete --cert-name example.comHäufige Probleme
"Challenge failed"
- DNS zeigt nicht auf Server
- Port 80 blockiert
- Webserver-Konfiguration falsch
Prüfen:
dig example.com +short
curl -I http://example.com/.well-known/acme-challenge/test"Rate limit exceeded"
Zu viele Anfragen in kurzer Zeit. Warten Sie eine Stunde.
Für Tests:
certbot --nginx --staging -d example.com"Unauthorized"
Meist DNS-Problem oder falsche Server-Konfiguration.
Best Practices
1. Redirects einrichten
HTTP auf HTTPS:
server {
listen 80;
server_name example.com;
return 301 https://$server_name$request_uri;
}2. HSTS aktivieren
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;3. Erneuerung testen
certbot renew --dry-run4. Monitoring
Zertifikats-Ablauf überwachen:
echo | openssl s_client -servername example.com -connect example.com:443 2>/dev/null | openssl x509 -noout -dates5. Staging für Tests
certbot --staging -d test.example.comStaging hat keine Rate-Limits.
Certbot-Befehle
| Aktion | Befehl | |--------|--------| | Neues Zertifikat | certbot --nginx -d domain.de | | Nur Zertifikat | certbot certonly --nginx -d domain.de | | Zertifikate anzeigen | certbot certificates | | Erneuerung testen | certbot renew --dry-run | | Manuell erneuern | certbot renew | | Zertifikat löschen | certbot delete --cert-name domain.de |
Alternative: acme.sh
Leichtgewichtige Alternative zu Certbot:
curl https://get.acme.sh | sh
acme.sh --issue -d example.com -w /var/www/html
acme.sh --install-cert -d example.com \
--key-file /etc/ssl/private/example.key \
--fullchain-file /etc/ssl/certs/example.crt \
--reloadcmd "systemctl reload nginx"Fazit
Certbot macht SSL-Zertifikate einfach. Die automatische Erneuerung sorgt für stets gültige Zertifikate. Einmal eingerichtet, läuft alles automatisch - Sie müssen sich um nichts mehr kümmern.