====== ACME Integration ======
**Komplexität:** Mittel \\
**Dauer:** 1-2 Stunden Setup \\
**Voraussetzung:** DNS/HTTP Challenge-Zugang
Integration des ACME-Protokolls (RFC 8555) für automatische Zertifikatserneuerung mit Post-Quantum-Unterstützung.
----
===== Architektur =====
sequenceDiagram
participant Client as ACME Client
participant CA as ACME CA
participant DNS as DNS/HTTP Server
participant App as Anwendung
Client->>CA: 1. Account erstellen
Client->>CA: 2. Order erstellen (CSR)
CA->>Client: 3. Challenge (DNS-01/HTTP-01)
Client->>DNS: 4. Challenge erfüllen
CA->>DNS: 5. Challenge validieren
CA->>Client: 6. Zertifikat ausstellen
Client->>App: 7. Zertifikat deployen
Client->>App: 8. Reload Service
----
===== Certbot Installation =====
# Debian/Ubuntu
apt update && apt install certbot python3-certbot-nginx
# RHEL/CentOS
dnf install certbot python3-certbot-nginx
# Mit DNS-Plugin (Cloudflare)
apt install python3-certbot-dns-cloudflare
----
===== HTTP-01 Challenge =====
**Für öffentlich erreichbare Webserver:**
# Nginx
certbot --nginx -d example.com -d www.example.com
# Apache
certbot --apache -d example.com -d www.example.com
# Standalone (Port 80 frei)
certbot certonly --standalone -d example.com
# Webroot (existierender Server)
certbot certonly --webroot -w /var/www/html -d example.com
**Auto-Renewal Cron:**
# Automatisch bei certbot-Installation aktiviert
# Manuell prüfen:
systemctl status certbot.timer
# Manueller Test
certbot renew --dry-run
----
===== DNS-01 Challenge =====
**Für interne Server oder Wildcards:**
==== Cloudflare ====
# /etc/letsencrypt/cloudflare.ini
dns_cloudflare_api_token = YOUR_API_TOKEN
chmod 600 /etc/letsencrypt/cloudflare.ini
certbot certonly \
--dns-cloudflare \
--dns-cloudflare-credentials /etc/letsencrypt/cloudflare.ini \
-d example.com \
-d "*.example.com"
==== Route53 (AWS) ====
# AWS Credentials in ~/.aws/credentials
certbot certonly \
--dns-route53 \
-d example.com \
-d "*.example.com"
==== Azure DNS ====
# Mit certbot-dns-azure Plugin
pip install certbot-dns-azure
certbot certonly \
--authenticator dns-azure \
--dns-azure-credentials /etc/letsencrypt/azure.ini \
-d example.com
----
===== Deployment Hooks =====
Hooks werden nach erfolgreicher Erneuerung ausgeführt.
==== Nginx Reload ====
# /etc/letsencrypt/renewal-hooks/deploy/reload-nginx.sh
#!/bin/bash
systemctl reload nginx
echo "$(date): Nginx reloaded" >> /var/log/certbot-deploy.log
chmod +x /etc/letsencrypt/renewal-hooks/deploy/reload-nginx.sh
==== Apache Reload ====
# /etc/letsencrypt/renewal-hooks/deploy/reload-apache.sh
#!/bin/bash
systemctl reload apache2
==== Docker Container ====
# /etc/letsencrypt/renewal-hooks/deploy/docker-reload.sh
#!/bin/bash
docker exec nginx nginx -s reload
# oder
docker-compose restart nginx
==== Benachrichtigung ====
# /etc/letsencrypt/renewal-hooks/post/notify.sh
#!/bin/bash
DOMAINS=$(echo $RENEWED_DOMAINS | tr ' ' '\n')
echo "Erneuert: $DOMAINS" | mail -s "Zertifikat erneuert" admin@example.com
----
===== Private ACME CA (Step-CA) =====
Für interne PKI mit ACME-Unterstützung:
# Step-CA installieren
wget https://github.com/smallstep/certificates/releases/download/v0.25.0/step-ca_0.25.0_amd64.deb
dpkg -i step-ca_0.25.0_amd64.deb
# CA initialisieren
step ca init --name="Internal CA" --dns=ca.internal.example.com --address=:443
**ACME Provisioner hinzufügen:**
step ca provisioner add acme --type ACME
**Certbot mit privater CA:**
certbot certonly \
--server https://ca.internal.example.com/acme/acme/directory \
--standalone \
-d internal-server.example.com
----
===== Post-Quantum Hinweis =====
**Stand 2024:** ACME-Protokoll und Let's Encrypt unterstützen noch keine PQ-Signaturen.
**Hybrid-Strategie:**
# 1. ACME-Zertifikat für TLS-Handshake (ECDSA)
certbot certonly --nginx -d example.com
# 2. Zusätzliches PQ-Zertifikat für Hybrid-Modus
# (parallel via eigene PKI mit WvdS)
// C#: Hybrid-Zertifikat parallel erstellen
using var ecdsa = ECDsa.Create(ECCurve.NamedCurves.nistP384);
var request = new CertificateRequest(
"CN=example.com", ecdsa, HashAlgorithmName.SHA384);
// Mit PQ-Extension für zukunftssichere Clients
var cert = request.CreateSelfSigned(
DateTimeOffset.UtcNow,
DateTimeOffset.UtcNow.AddDays(90),
CryptoMode.Hybrid);
----
===== Monitoring =====
# Certbot Logs
tail -f /var/log/letsencrypt/letsencrypt.log
# Zertifikat-Ablauf prüfen
certbot certificates
# Prometheus Exporter (cert-exporter)
# Überwacht alle Zertifikate auf Ablauf
----
===== Fehlerbehebung =====
| Problem | Ursache | Lösung |
|---------|---------|--------|
| ''Challenge failed'' | Port 80/443 blockiert | Firewall prüfen |
| ''DNS propagation'' | DNS-Cache | Warten (bis 60 Min) oder TTL reduzieren |
| ''Rate limit exceeded'' | Zu viele Requests | Staging-Server nutzen |
| ''unauthorized'' | Domain-Validierung fehlgeschlagen | DNS-Einträge prüfen |
# Staging-Server für Tests (keine Rate-Limits)
certbot certonly --staging --nginx -d test.example.com
# Debug-Modus
certbot certonly --nginx -d example.com --debug
----
===== Checkliste =====
| # | Prüfpunkt | ✓ |
|---|-----------|---|
| 1 | DNS/HTTP Challenge konfiguriert | ☐ |
| 2 | Certbot installiert und getestet | ☐ |
| 3 | Auto-Renewal aktiviert (Timer) | ☐ |
| 4 | Deploy-Hook konfiguriert | ☐ |
| 5 | Monitoring eingerichtet | ☐ |
| 6 | Benachrichtigung bei Fehler | ☐ |
----
===== Verwandte Dokumentation =====
* [[.:scheduled-renewal|Scheduled Renewal]] – Alternative ohne ACME
* [[..:monitoring:ablauf-monitoring|Ablauf-Monitoring]] – Zertifikate überwachen
* [[de:int:pqcrypt:szenarien:tls:start|TLS/mTLS]] – Server-Konfiguration
----
<< [[.:start|← Automatisierung]] | [[.:cicd-code-signing|→ CI/CD Code-Signing]] >>
----
//Wolfgang van der Stille @ EMSR DATA d.o.o. - Post-Quantum Cryptography Professional//
{{tag>acme letsencrypt certbot automatisierung operator}}