Files
mtusi2026lab7-safronov/evidence/security/api-tls.md
T
2026-11-16 06:49:52 +03:00

47 lines
2.0 KiB
Markdown

# TLS процесса API (change `pki-ingress-mtls`)
Дата: 2026-11-16. Код: `5c514b0` и рабочее дерево apply (до коммита). Спеки
`transport-security` («TLS API обязателен на стенде», «Консоль по HTTPS», «Health без обхода
бизнес-API»), `container-image` («Healthcheck без сертификата клиента»). Путь репозитория —
`<repo>`.
## Консоль по HTTPS (задача 4.3)
`make run_dev`: `pki_stand`, миграции, Valkey, S3, брокер, затем процесс с
`API_TLS__CERT_FILE` / `API_TLS__KEY_FILE` identity `ingress` (SAN `localhost`) и
`API_TLS__CLIENT_AUTH=false`. Запись о старте называет режим TLS без путей, слушателя health в
консоли нет:
```
$ make run_dev
…
{"event": "Uvicorn running on https://127.0.0.1:8080 (Press CTRL+C to quit)", …}
{"event": "Started API", …, "tls_client_auth": false, "tls_allowed_clients": 0, "health_port": null, …}
```
Публичный smoke по HTTPS с CA стенда по умолчанию (`CA_FILE` Makefile), HTTP открытым текстом
на том же порту HTTP-ответа не получает:
```
$ make test BASE_URL=https://localhost:8080
python3 tests/smoke.py --base-url "https://localhost:8080" --ca-file "<repo>/.pki/stand/ca.crt"
PASS: lab7 public API scenario; infrastructure and grading evidence remain separate.
exit=0
$ curl -sS --max-time 5 http://localhost:8080/health/live
curl: (52) Empty reply from server
exit=52
$ curl -sS --cacert .pki/stand/ca.crt -o /dev/null -w "%{http_code} %{ssl_verify_result}\n" https://localhost:8080/health/live
200 0
```
`CA_FILE` по умолчанию и из командной строки:
```
$ make -n test | head -1
python3 tests/smoke.py --base-url "https://localhost:8443" --ca-file "<repo>/.pki/stand/ca.crt"
$ make -n test CA_FILE=/x | head -1
python3 tests/smoke.py --base-url "https://localhost:8443" --ca-file "/x"
```