Durata: ~15 minuti
Ruolo: Operatore PKI
Trigger: Avviso scadenza (30/14/7 giorni)
# Tutti i certificati con scadenza < 30 giorni find /etc/ssl/certs -name "*.pem" -exec sh -c ' enddate=$(openssl x509 -enddate -noout -in "$1" 2>/dev/null | cut -d= -f2) if [ -n "$enddate" ]; then expiry=$(date -d "$enddate" +%s 2>/dev/null) now=$(date +%s) days=$(( (expiry - now) / 86400 )) if [ "$days" -lt 30 ]; then echo "$1: $days giorni" fi fi ' _ {} \;
# PowerShell: Trovare certificati in scadenza Get-ChildItem Cert:\LocalMachine\My | Where-Object { $_.NotAfter -lt (Get-Date).AddDays(30) } | Select-Object Subject, NotAfter, Thumbprint
| Metodo | Quando usare | Vantaggio |
| ——— | —————- | ——— |
| Re-Certification | Chiave sicura, nessuna modifica | Veloce, nessun re-deploy |
| Re-Key | Nuova lunghezza chiave, cambio policy | Maggiore sicurezza |
| Replace | Nuovo algoritmo (→ PQ) | A prova di futuro |
# Generare CSR da certificato esistente + chiave openssl x509 -x509toreq -in old_cert.pem -signkey private.key -out renew.csr # Emettere nuovo certificato openssl ca -config openssl.cnf \ -extensions server_cert \ -in renew.csr \ -out renewed_cert.pem \ -days 365 \ -notext
# Generare nuova chiave (EC P-384) openssl ecparam -genkey -name secp384r1 -out new_private.key # Nuovo CSR con stesso Subject openssl req -new -key new_private.key -out rekey.csr \ -subj "$(openssl x509 -in old_cert.pem -subject -noout | sed 's/subject=//')" # Emettere certificato openssl ca -config openssl.cnf \ -extensions server_cert \ -in rekey.csr \ -out rekeyed_cert.pem \ -days 365
// Migrazione a modalità ibrida using var oldCert = new X509Certificate2("old_cert.pfx", "password"); // Nuova coppia di chiavi (ML-DSA-65 per Hybrid) using var mlDsa = MlDsaSigner.Create(MlDsaParameterSet.MlDsa65); using var ecdsa = ECDsa.Create(ECCurve.NamedCurves.nistP384); var request = new CertificateRequest( oldCert.SubjectName, ecdsa, HashAlgorithmName.SHA384); // Copiare estensioni foreach (var ext in oldCert.Extensions) request.CertificateExtensions.Add(ext); // Creare certificato ibrido var newCert = request.CreateSelfSigned( DateTimeOffset.UtcNow, DateTimeOffset.UtcNow.AddDays(365), CryptoMode.Hybrid);
# Archiviare con metadati ARCHIVE_DIR="/var/archive/certs/$(date +%Y)" mkdir -p "$ARCHIVE_DIR" # Certificato + metadati cp old_cert.pem "$ARCHIVE_DIR/$(openssl x509 -serial -noout -in old_cert.pem | cut -d= -f2).pem" # Log archivio echo "$(date -Iseconds) RENEWED $(openssl x509 -serial -noout -in old_cert.pem)" >> /var/log/cert-archive.log
| Sistema | Metodo deployment | Riavvio necessario |
| ——– | ——————- | ———————- |
| Apache | cp cert.pem /etc/ssl/; systemctl reload apache2 | No |
| Nginx | cp cert.pem /etc/nginx/ssl/; nginx -s reload | No |
| IIS | Import-PfxCertificate; netsh http update | No |
| Kubernetes | kubectl create secret tls | Restart Pod |
# Apache/Nginx Reload systemctl reload apache2 # oppure nginx -s reload # Test connessione openssl s_client -connect server.example.com:443 -brief
# Inserire nuovo fingerprint nel monitoring NEW_FP=$(openssl x509 -fingerprint -sha256 -noout -in renewed_cert.pem | cut -d= -f2) echo "Nuovo fingerprint: $NEW_FP" # Aggiornare alert Prometheus (se basato su fingerprint) # La data di scadenza nel monitoring dovrebbe aggiornarsi automaticamente
| # | Punto di verifica | Comando | |
| — | ———– | ——– | — |
| 1 | Nuovo certificato attivo | openssl s_client -connect host:443 | |
| 2 | Catena completa | openssl verify -CAfile chain.pem cert.pem | |
| 3 | Vecchio certificato archiviato | ls /var/archive/certs/ | |
| 4 | Ticket chiuso | Sistema ticket | |
| 5 | Monitoring aggiornato | Verificare dashboard |
| Problema | Causa | Soluzione |
| ——— | ——— | ——– |
certificate has expired | Reload dimenticato | Riavviare servizio |
certificate chain incomplete | Manca intermediate | cat cert.pem intermediate.pem > fullchain.pem |
hostname mismatch | SAN non aggiornato | CSR con SAN corretti |
| Client non si fida | CA non nello store | Distribuire certificato CA |
« Emissione certificato | Revoca certificato »
Wolfgang van der Stille @ EMSR DATA d.o.o. - Post-Quantum Cryptography Professional