Durata: ~15 minuti
Ruolo: Security-Admin
Prerequisito: Certificato (PFX o PEM+KEY)
Attivare HTTPS per il Data Gateway.
Opzione A: Let's Encrypt (gratuito)
# Installare Certbot sudo apt install certbot # Richiedere certificato sudo certbot certonly --standalone -d gateway.example.com # Risultato: # /etc/letsencrypt/live/gateway.example.com/fullchain.pem # /etc/letsencrypt/live/gateway.example.com/privkey.pem
Opzione B: Autofirmato (solo Test!)
# Creare certificato autofirmato openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365 -nodes \ -subj "/CN=gateway.example.com" # Convertire in PFX openssl pkcs12 -export -out gateway.pfx -inkey key.pem -in cert.pem -passout pass:changeit
Opzione C: CA Interna
→ Vedere PQ Crypto: Emettere certificato
# Windows mkdir %GATEWAY_ROOT%\certs copy gateway.pfx %GATEWAY_ROOT%\certs\ # Linux sudo mkdir -p /opt/data-gateway/certs sudo cp cert.pem key.pem /opt/data-gateway/certs/ sudo chmod 600 /opt/data-gateway/certs/* sudo chown datagateway:datagateway /opt/data-gateway/certs/*
Con file PFX:
{
"Kestrel": {
"Endpoints": {
"Https": {
"Url": "https://0.0.0.0:443",
"Certificate": {
"Path": "certs/gateway.pfx",
"Password": "changeit"
}
}
}
}
}
Con file PEM:
{
"Kestrel": {
"Endpoints": {
"Https": {
"Url": "https://0.0.0.0:443",
"Certificate": {
"Path": "certs/cert.pem",
"KeyPath": "certs/key.pem"
}
}
}
}
}
Forzare versione TLS:
{
"Kestrel": {
"Endpoints": {
"Https": {
"Url": "https://0.0.0.0:443",
"Certificate": {
"Path": "certs/gateway.pfx",
"Password": "changeit"
},
"SslProtocols": ["Tls12", "Tls13"]
}
}
}
}
# Windows Restart-Service -Name "DataGateway" # Linux sudo systemctl restart data-gateway # Docker docker restart gateway
# Test semplice curl -k https://localhost/health # Con verifica certificato curl https://gateway.example.com/health # Mostrare dettagli TLS curl -v https://gateway.example.com/health 2>&1 | grep -E "SSL|TLS|subject|expire" # Test OpenSSL openssl s_client -connect gateway.example.com:443 -servername gateway.example.com
Permettere solo HTTPS:
{
"Kestrel": {
"Endpoints": {
"Https": {
"Url": "https://0.0.0.0:443",
"Certificate": {
"Path": "certs/gateway.pfx",
"Password": "changeit"
}
}
}
}
}
Oppure Redirect HTTP→HTTPS:
// Program.cs app.UseHttpsRedirection();
| # | Punto di verifica | v |
| — | ———– | — |
| 1 | Certificato valido (non scaduto) | ☐ |
| 2 | Certificato per hostname corretto | ☐ |
| 3 | Private Key protetta (chmod 600) | ☐ |
| 4 | HTTPS raggiungibile | ☐ |
| 5 | TLS 1.2+ attivo | ☐ |
| 6 | HTTP disattivato o Redirect | ☐ |
| 7 | Firewall porta 443 aperta | ☐ |
| Problema | Causa | Soluzione |
| ——— | ——— | ——– |
Unable to configure HTTPS | Percorso errato | Verificare percorso certificato |
Password incorrect | Password PFX errata | Verificare password |
Certificate expired | Certificato scaduto | Nuovo certificato |
SSL_ERROR_RX_RECORD_TOO_LONG | HTTP invece di HTTPS | Verificare porta/protocollo |
NET::ERR_CERT_COMMON_NAME_INVALID | CN/SAN errato | Certificato con nome corretto |
« <- Sicurezza | -> Rinnovare certificato »
Wolfgang van der Stille @ EMSR DATA d.o.o. - Data Gateway Professional