Files
aza/AzA march 2026 - Kopie (2)/security/handovers/STEP_4_1_TLS.md
2026-03-30 07:59:11 +02:00

101 lines
3.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# STEP 4.1 TLS-PFLICHT FÜR ALLE BACKEND-SERVICES
# Status: ABGESCHLOSSEN
---
## Ziel
GAP #4: Alle Backend-Services von HTTP auf HTTPS/TLS umstellen.
Fail-Start bei fehlendem Zertifikat im Produktionsmodus.
## Geänderte Dateien
| Datei | Änderung |
|-------|----------|
| **aza_tls.py** | NEU Zentrale TLS-Konfiguration |
| **todo_server.py** | TLS-Integration via create_ssl_context() |
| **transcribe_server.py** | TLS-Integration via uvicorn SSL-Kwargs |
| **backend_main.py** | TLS-Integration via uvicorn SSL-Kwargs |
## TLS-Parameter
| Parameter | Wert |
|-----------|------|
| Minimale TLS-Version | 1.2 (konfigurierbar via ENV) |
| Maximale TLS-Version | 1.3 |
| Cipher Suites | ECDHE+AESGCM, ECDHE+CHACHA20, DHE+AESGCM, DHE+CHACHA20 |
| Ausgeschlossen | aNULL, eNULL, MD5, DSS, RC4, 3DES |
| Perfect Forward Secrecy | Ja (nur ECDHE/DHE Cipher erlaubt) |
| DEV-Zertifikat | RSA 4096-bit, SHA-256, 365 Tage, Self-Signed |
| PROD-Vorbereitung | Pfade über ENV-Variablen konfigurierbar (ACME/Let's Encrypt) |
## Umgebungsvariablen
| Variable | Default | Beschreibung |
|----------|---------|--------------|
| AZA_TLS_CERTFILE | (leer) | Pfad zum Zertifikat (PEM) |
| AZA_TLS_KEYFILE | (leer) | Pfad zum Private Key (PEM) |
| AZA_TLS_MIN_VERSION | "1.2" | Minimale TLS-Version ("1.2" oder "1.3") |
| AZA_TLS_REQUIRE | "1" | "1" = Fail-Start ohne Zertifikat |
## Betroffene Server
| Server | Port | Typ | TLS-Methode |
|--------|------|-----|-------------|
| todo_server | 5111 | stdlib HTTPServer | ssl.wrap_socket() |
| transcribe_server | 8090 | FastAPI/Uvicorn | uvicorn ssl_certfile/ssl_keyfile |
| backend_main | 8000 | FastAPI/Uvicorn | uvicorn ssl_certfile/ssl_keyfile |
| workforce_planner | variabel | FastAPI/Uvicorn | Nicht geändert (kein __main__-Block) |
## Testmethode
### DEV-Zertifikat erstellen:
```
python aza_tls.py
```
### Server starten:
```
set AZA_TLS_CERTFILE=dev-cert.pem
set AZA_TLS_KEYFILE=dev-key.pem
python backend_main.py
```
### Testen:
```
curl https://localhost:8000/health --insecure
```
### Fail-Start testen (ohne Zertifikat):
```
set AZA_TLS_REQUIRE=1
python backend_main.py
→ Muss mit Fehlermeldung abbrechen
```
### DEV-Modus ohne TLS:
```
set AZA_TLS_REQUIRE=0
python backend_main.py
→ Startet auf HTTP mit Warnung
```
## Rest-Risiken
1. **workforce_planner**: Hat keinen eigenen __main__-Block. TLS muss beim
Start via uvicorn CLI konfiguriert werden:
`uvicorn workforce_planner.api.app:app --ssl-certfile=... --ssl-keyfile=...`
2. **Self-Signed Zertifikat**: Browser und Clients zeigen Warnungen.
Für Produktion muss ein CA-signiertes Zertifikat verwendet werden.
3. **Client-Seite**: Die Clients (basis14.py, aza_diktat_mixin.py) müssen
ihre Server-URLs von http:// auf https:// ändern das ist ein separater
Schritt.
4. **Zertifikatsrotation**: Kein automatischer Erneuerungsmechanismus
implementiert. Für PROD wird ACME/certbot empfohlen.
5. **todo_server PWA**: Service Worker erfordert HTTPS für vollständige
Funktionalität auf iPhones dies ist jetzt möglich.