Durata: ~10 minuti
Ruolo: Security-Admin
Frequenza: Ogni 90 giorni (Let's Encrypt) o annuale
Rinnovo del certificato TLS per il Data Gateway.
# Verificare certificato attuale openssl s_client -connect gateway.example.com:443 -servername gateway.example.com 2>/dev/null | \ openssl x509 -noout -dates # Giorni alla scadenza echo | openssl s_client -connect gateway.example.com:443 2>/dev/null | \ openssl x509 -noout -enddate | \ cut -d= -f2 | \ xargs -I {} bash -c 'echo "Giorni alla scadenza: $(( ($(date -d "{}" +%s) - $(date +%s)) / 86400 ))"'
# Automatico (se certbot configurato correttamente) sudo certbot renew # Con Pre/Post-Hook per Gateway sudo certbot renew \ --pre-hook "systemctl stop data-gateway" \ --post-hook "systemctl start data-gateway" # Dry run (senza rinnovo effettivo) sudo certbot renew --dry-run
Automazione via Cron:
# /etc/cron.d/certbot-gateway 0 3 * * * root certbot renew --quiet --post-hook "systemctl reload data-gateway"
# Creare CSR openssl req -new -key gateway.key -out gateway.csr \ -subj "/CN=gateway.example.com/O=Example Corp" # Inviare CSR alla CA (es. via PQ Crypto) # -> Nuovo certificato: gateway-new.crt
Vedere: PQ Crypto: Rinnovare certificato
1. Accedere presso il fornitore (DigiCert, GlobalSign, ecc.) 2. Richiedere rinnovo 3. Caricare CSR o rigenerare 4. Effettuare validazione 5. Scaricare nuovo certificato
# Creare backup cp /opt/data-gateway/certs/gateway.pfx /opt/data-gateway/certs/gateway.pfx.bak.$(date +%Y%m%d) # Oppure per PEM cp /opt/data-gateway/certs/cert.pem /opt/data-gateway/certs/cert.pem.bak.$(date +%Y%m%d)
# Formato PEM sudo cp new-cert.pem /opt/data-gateway/certs/cert.pem sudo cp new-key.pem /opt/data-gateway/certs/key.pem sudo chmod 600 /opt/data-gateway/certs/*.pem # Formato PFX sudo cp new-gateway.pfx /opt/data-gateway/certs/gateway.pfx sudo chmod 600 /opt/data-gateway/certs/gateway.pfx
# Linux sudo systemctl restart data-gateway # Windows Restart-Service -Name "DataGateway" # Docker docker restart gateway # Kubernetes (Rolling Update) kubectl rollout restart deployment/data-gateway -n data-gateway
# Nuovo certificato attivo? echo | openssl s_client -connect gateway.example.com:443 2>/dev/null | \ openssl x509 -noout -subject -dates # Health Check curl https://gateway.example.com/health # Test SSL completo openssl s_client -connect gateway.example.com:443 -servername gateway.example.com
# Ripristinare backup sudo cp /opt/data-gateway/certs/gateway.pfx.bak.20241215 /opt/data-gateway/certs/gateway.pfx # Riavviare Gateway sudo systemctl restart data-gateway # Verificare curl https://gateway.example.com/health
| # | Punto di verifica | v |
| — | ———– | — |
| 1 | Vecchio certificato salvato | ☐ |
| 2 | Nuovo certificato valido | ☐ |
| 3 | Hostname corrispondono | ☐ |
| 4 | Certificato installato | ☐ |
| 5 | Gateway riavviato | ☐ |
| 6 | HTTPS funzionante | ☐ |
| 7 | Monitoring notificato | ☐ |
| Problema | Causa | Soluzione |
| ——— | ——— | ——– |
Certificate mismatch | Key non corrisponde | Rigenerare key |
Chain incomplete | Intermediate mancante | Aggiungere file chain |
Permission denied | Permessi errati | chmod 600 |
| Gateway non si avvia | Password errata | Verificare appsettings.json |
Alert Prometheus per scadenza certificato:
- alert: GatewayCertExpiringSoon expr: | (probe_ssl_earliest_cert_expiry{job="gateway-tls"} - time()) / 86400 < 14 for: 1h labels: severity: warning annotations: summary: "Certificato Gateway in scadenza" description: "Il certificato scade tra {{ $value | humanize }} giorni."
« <- Configurare TLS | -> Regole Firewall »
Wolfgang van der Stille @ EMSR DATA d.o.o. - Data Gateway Professional