Complessità: Media
Durata: 1-2 ore di configurazione
Prerequisito: Accesso DNS/HTTP Challenge
Integrazione del protocollo ACME (RFC 8555) per il rinnovo automatico dei certificati con supporto Post-Quantum.
# Debian/Ubuntu apt update && apt install certbot python3-certbot-nginx # RHEL/CentOS dnf install certbot python3-certbot-nginx # Con plugin DNS (Cloudflare) apt install python3-certbot-dns-cloudflare
Per server web raggiungibili pubblicamente:
# Nginx certbot --nginx -d example.com -d www.example.com # Apache certbot --apache -d example.com -d www.example.com # Standalone (porta 80 libera) certbot certonly --standalone -d example.com # Webroot (server esistente) certbot certonly --webroot -w /var/www/html -d example.com
Cron per rinnovo automatico:
# Attivato automaticamente con l'installazione di certbot # Verifica manuale: systemctl status certbot.timer # Test manuale certbot renew --dry-run
Per server interni o wildcard:
# /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"
# Credenziali AWS in ~/.aws/credentials certbot certonly \ --dns-route53 \ -d example.com \ -d "*.example.com"
# Con plugin certbot-dns-azure pip install certbot-dns-azure certbot certonly \ --authenticator dns-azure \ --dns-azure-credentials /etc/letsencrypt/azure.ini \ -d example.com
Gli hook vengono eseguiti dopo un rinnovo riuscito.
# /etc/letsencrypt/renewal-hooks/deploy/reload-nginx.sh #!/bin/bash systemctl reload nginx echo "$(date): Nginx ricaricato" >> /var/log/certbot-deploy.log
chmod +x /etc/letsencrypt/renewal-hooks/deploy/reload-nginx.sh
# /etc/letsencrypt/renewal-hooks/deploy/reload-apache.sh #!/bin/bash systemctl reload apache2
# /etc/letsencrypt/renewal-hooks/deploy/docker-reload.sh #!/bin/bash docker exec nginx nginx -s reload # oppure docker-compose restart nginx
# /etc/letsencrypt/renewal-hooks/post/notify.sh #!/bin/bash DOMAINS=$(echo $RENEWED_DOMAINS | tr ' ' '\n') echo "Rinnovato: $DOMAINS" | mail -s "Certificato rinnovato" admin@example.com
Per PKI interna con supporto ACME:
# Installazione Step-CA 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 # Inizializzazione CA step ca init --name="Internal CA" --dns=ca.internal.example.com --address=:443
Aggiunta provisioner ACME:
step ca provisioner add acme --type ACME
Certbot con CA privata:
certbot certonly \
--server https://ca.internal.example.com/acme/acme/directory \
--standalone \
-d internal-server.example.com
Stato 2024: Il protocollo ACME e Let's Encrypt non supportano ancora firme PQ.
Strategia ibrida:
# 1. Certificato ACME per handshake TLS (ECDSA) certbot certonly --nginx -d example.com # 2. Certificato PQ aggiuntivo per modalità ibrida # (in parallelo tramite PKI propria con WvdS)
// C#: Creazione certificato ibrido in parallelo using var ecdsa = ECDsa.Create(ECCurve.NamedCurves.nistP384); var request = new CertificateRequest( "CN=example.com", ecdsa, HashAlgorithmName.SHA384); // Con estensione PQ per client pronti per il futuro var cert = request.CreateSelfSigned( DateTimeOffset.UtcNow, DateTimeOffset.UtcNow.AddDays(90), CryptoMode.Hybrid);
# Log Certbot tail -f /var/log/letsencrypt/letsencrypt.log # Verifica scadenza certificato certbot certificates # Prometheus Exporter (cert-exporter) # Monitora tutti i certificati per la scadenza
| Problema | Causa | Soluzione |
| ———- | ——- | ———– |
Challenge failed | Porta 80/443 bloccata | Verificare firewall |
DNS propagation | Cache DNS | Attendere (fino a 60 min) o ridurre TTL |
Rate limit exceeded | Troppe richieste | Usare server staging |
unauthorized | Validazione dominio fallita | Verificare record DNS |
# Server staging per test (nessun limite di rate) certbot certonly --staging --nginx -d test.example.com # Modalità debug certbot certonly --nginx -d example.com --debug
| # | Punto di verifica | ✓ |
| — | ——————- | — |
| 1 | DNS/HTTP Challenge configurato | ☐ |
| 2 | Certbot installato e testato | ☐ |
| 3 | Rinnovo automatico attivato (Timer) | ☐ |
| 4 | Hook di distribuzione configurato | ☐ |
| 5 | Monitoraggio configurato | ☐ |
| 6 | Notifica in caso di errore | ☐ |
« ← Automazione | → Code-Signing CI/CD »
Wolfgang van der Stille @ EMSR DATA d.o.o. - Post-Quantum Cryptography Professional