====== Runbook: TLS einrichten ====== **Dauer:** ~15 Minuten \\ **Rolle:** Security-Admin \\ **Voraussetzung:** Zertifikat (PFX oder PEM+KEY) HTTPS für das Data Gateway aktivieren. ---- ===== Workflow ===== flowchart TD A[Start] --> B{Zertifikat vorhanden?} B -->|Nein| C[Zertifikat beschaffen] B -->|Ja| D[appsettings.json anpassen] C --> D D --> E[Gateway neustarten] E --> F[HTTPS testen] F --> G{Erfolgreich?} G -->|Ja| H[HTTP deaktivieren] G -->|Nein| I[Logs prüfen] H --> J[Fertig] style J fill:#e8f5e9 style I fill:#ffebee ---- ===== 1. Zertifikat beschaffen ===== **Option A: Let's Encrypt (kostenlos)** # Certbot installieren sudo apt install certbot # Zertifikat anfordern sudo certbot certonly --standalone -d gateway.example.com # Ergebnis: # /etc/letsencrypt/live/gateway.example.com/fullchain.pem # /etc/letsencrypt/live/gateway.example.com/privkey.pem **Option B: Selbstsigniert (nur Test!)** # Selbstsigniertes Zertifikat erstellen openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365 -nodes \ -subj "/CN=gateway.example.com" # In PFX konvertieren openssl pkcs12 -export -out gateway.pfx -inkey key.pem -in cert.pem -passout pass:changeit **Option C: Interne CA** → Siehe [[de:int:pqcrypt:szenarien:operator:tagesgeschaeft:zertifikat-ausstellen|PQ Crypto: Zertifikat ausstellen]] ---- ===== 2. Zertifikat ablegen ===== # 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/* ---- ===== 3. appsettings.json konfigurieren ===== **Mit PFX-Datei:** { "Kestrel": { "Endpoints": { "Https": { "Url": "https://0.0.0.0:443", "Certificate": { "Path": "certs/gateway.pfx", "Password": "changeit" } } } } } **Mit PEM-Dateien:** { "Kestrel": { "Endpoints": { "Https": { "Url": "https://0.0.0.0:443", "Certificate": { "Path": "certs/cert.pem", "KeyPath": "certs/key.pem" } } } } } **TLS-Version erzwingen:** { "Kestrel": { "Endpoints": { "Https": { "Url": "https://0.0.0.0:443", "Certificate": { "Path": "certs/gateway.pfx", "Password": "changeit" }, "SslProtocols": ["Tls12", "Tls13"] } } } } ---- ===== 4. Gateway neustarten ===== # Windows Restart-Service -Name "DataGateway" # Linux sudo systemctl restart data-gateway # Docker docker restart gateway ---- ===== 5. HTTPS testen ===== # Einfacher Test curl -k https://localhost/health # Mit Zertifikat-Prüfung curl https://gateway.example.com/health # TLS-Details anzeigen curl -v https://gateway.example.com/health 2>&1 | grep -E "SSL|TLS|subject|expire" # OpenSSL-Test openssl s_client -connect gateway.example.com:443 -servername gateway.example.com ---- ===== 6. HTTP deaktivieren (optional) ===== Nur HTTPS erlauben: { "Kestrel": { "Endpoints": { "Https": { "Url": "https://0.0.0.0:443", "Certificate": { "Path": "certs/gateway.pfx", "Password": "changeit" } } } } } Oder HTTP→HTTPS Redirect: // Program.cs app.UseHttpsRedirection(); ---- ===== 7. Checkliste ===== | # | Prüfpunkt | ✓ | |---|-----------|---| | 1 | Zertifikat gültig (nicht abgelaufen) | ☐ | | 2 | Zertifikat für korrekten Hostnamen | ☐ | | 3 | Private Key geschützt (chmod 600) | ☐ | | 4 | HTTPS erreichbar | ☐ | | 5 | TLS 1.2+ aktiv | ☐ | | 6 | HTTP deaktiviert oder Redirect | ☐ | | 7 | Firewall Port 443 offen | ☐ | ---- ===== Troubleshooting ===== | Problem | Ursache | Lösung | |---------|---------|--------| | ''Unable to configure HTTPS'' | Falscher Pfad | Zertifikat-Pfad prüfen | | ''Password incorrect'' | Falsches PFX-Passwort | Passwort prüfen | | ''Certificate expired'' | Zertifikat abgelaufen | Neues Zertifikat | | ''SSL_ERROR_RX_RECORD_TOO_LONG'' | HTTP statt HTTPS | Port/Protocol prüfen | | ''NET::ERR_CERT_COMMON_NAME_INVALID'' | CN/SAN falsch | Zertifikat mit richtigem Namen | ---- ===== SSL-Test online ===== Für öffentlich erreichbare Server: * **SSL Labs:** [[https://www.ssllabs.com/ssltest/|ssllabs.com/ssltest]] * **Qualys:** Grade A+ anstreben ---- ===== Verwandte Runbooks ===== * [[.:zertifikat-erneuern|Zertifikat erneuern]] – Renewal-Prozess * [[.:firewall-regeln|Firewall-Regeln]] – Port 443 freigeben * [[..:monitoring:alerting|Alerting]] – Zertifikats-Überwachung ---- << [[.:start|← Sicherheit]] | [[.:zertifikat-erneuern|→ Zertifikat erneuern]] >> ---- //Wolfgang van der Stille @ EMSR DATA d.o.o. - Data Gateway Professional// {{tag>operator runbook tls https zertifikat ssl}}