forked from mtusi2026/mtusi2026lab7
fix: address verify remarks for pki-ingress-mtls
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,10 +1,18 @@
|
||||
# mTLS LB → API: отрицательные проверки (change `pki-ingress-mtls`)
|
||||
|
||||
Дата: 2026-11-16. Код: рабочее дерево поверх `4759f71` (apply, до коммита). Спек
|
||||
`transport-security`: «Обязательное mTLS балансировщика к репликам», «Allowlist identity
|
||||
Спек `transport-security`: «Обязательное mTLS балансировщика к репликам», «Allowlist identity
|
||||
клиента реплики», «Отрицательные проверки LB → API одной командой»; design, решение 12. Путь
|
||||
репозитория — `<repo>`.
|
||||
|
||||
Код приложения на момент съёмки:
|
||||
|
||||
- «Штатный стенд — код 0» — 2026-11-17, `2649eb2` (правки verify: строка S1 драйвера, порт
|
||||
health одним источником W1, срок ответа слушателя health S2); рабочее дерево отличалось от
|
||||
него только документами и строкой справки драйвера;
|
||||
- «Расхождение называется — код 1» и «Уборка при Ctrl+C» — 2026-11-16, код приложения и стенда
|
||||
как в `50cb54f` (рабочее дерево поверх `4759f71`; `src/`, compose, `infra/`, `scripts/` с
|
||||
`4759f71` до `50cb54f` не менялись), драйвер — до строки S1.
|
||||
|
||||
Команда — `make mtls_check` (`driver.py --ca-file <CA стенда> --port 8443 mtls-check`). Проба —
|
||||
одноразовый контейнер на образе API (`python` и `ssl` образа) в сети стенда, к каждой реплике по
|
||||
её адресу с проверкой сервера (CA стенда, hostname `api`). Материалы — во временном каталоге
|
||||
@@ -24,39 +32,41 @@
|
||||
$ make mtls_check
|
||||
python3 .claude/skills/run-mtusi-messenger/driver.py --ca-file "<repo>/.pki/stand/ca.crt" --port 8443 mtls-check
|
||||
stand network mtusi-lab7_default, API image mtusi-messenger:lab7, replicas 2, API port 8080
|
||||
replica 4468cb13abcd0b10: no client certificate: no HTTP (closed: closed after handshake)
|
||||
replica 4468cb13abcd0b10: certificate of another CA (SAN haproxy): no HTTP (closed: closed after handshake)
|
||||
replica 4468cb13abcd0b10: forbidden identity of the stand CA (mtls-probe): no HTTP (closed: closed after handshake)
|
||||
replica 4468cb13abcd0b10: server certificate of the stand CA (ingress): no HTTP (closed: closed after handshake)
|
||||
replica 4468cb13abcd0b10: HTTP without TLS: no HTTP (closed: 0 bytes, no HTTP)
|
||||
replica 6a2affca29d0115f: no client certificate: no HTTP (closed: closed after handshake)
|
||||
replica 6a2affca29d0115f: certificate of another CA (SAN haproxy): no HTTP (closed: closed after handshake)
|
||||
replica 6a2affca29d0115f: forbidden identity of the stand CA (mtls-probe): no HTTP (closed: closed after handshake)
|
||||
replica 6a2affca29d0115f: server certificate of the stand CA (ingress): no HTTP (closed: closed after handshake)
|
||||
replica 6a2affca29d0115f: HTTP without TLS: no HTTP (closed: 0 bytes, no HTTP)
|
||||
replica 67c6a50d6592a774: no client certificate: no HTTP (closed: closed after handshake)
|
||||
replica 67c6a50d6592a774: certificate of another CA (SAN haproxy): no HTTP (closed: closed after handshake)
|
||||
replica 67c6a50d6592a774: forbidden identity of the stand CA (mtls-probe): no HTTP (closed: closed after handshake)
|
||||
replica 67c6a50d6592a774: server certificate of the stand CA (ingress): no HTTP (closed: closed after handshake)
|
||||
replica 67c6a50d6592a774: HTTP without TLS: no HTTP (closed: 0 bytes, no HTTP)
|
||||
replica cccacf9b0540977e: no client certificate: no HTTP (closed: closed after handshake)
|
||||
replica cccacf9b0540977e: certificate of another CA (SAN haproxy): no HTTP (closed: closed after handshake)
|
||||
replica cccacf9b0540977e: forbidden identity of the stand CA (mtls-probe): no HTTP (closed: closed after handshake)
|
||||
replica cccacf9b0540977e: server certificate of the stand CA (ingress): no HTTP (closed: closed after handshake)
|
||||
replica cccacf9b0540977e: HTTP without TLS: no HTTP (closed: 0 bytes, no HTTP)
|
||||
foreign server 192.168.176.13: LB slot DOWN
|
||||
20 requests through LB: {'200 6a2affca29d0115f': 10, '200 4468cb13abcd0b10': 10}
|
||||
replica 4468cb13abcd0b10: no client certificate expected no HTTP got no HTTP
|
||||
replica 4468cb13abcd0b10: certificate of another CA (SAN haproxy) expected no HTTP got no HTTP
|
||||
replica 4468cb13abcd0b10: forbidden identity of the stand CA (mtls-probe) expected no HTTP got no HTTP
|
||||
replica 4468cb13abcd0b10: server certificate of the stand CA (ingress) expected no HTTP got no HTTP
|
||||
replica 4468cb13abcd0b10: HTTP without TLS expected no HTTP got no HTTP
|
||||
replica 4468cb13abcd0b10: allowed identity haproxy expected HTTP 200 TLSv1.3 got HTTP 200 TLSv1.3
|
||||
replica 4468cb13abcd0b10: X-Instance-Id = alias from its log expected 4468cb13abcd0b10 got 4468cb13abcd0b10
|
||||
replica 4468cb13abcd0b10: 'Rejected TLS client' with mtls-probe expected yes got yes
|
||||
replica 6a2affca29d0115f: no client certificate expected no HTTP got no HTTP
|
||||
replica 6a2affca29d0115f: certificate of another CA (SAN haproxy) expected no HTTP got no HTTP
|
||||
replica 6a2affca29d0115f: forbidden identity of the stand CA (mtls-probe) expected no HTTP got no HTTP
|
||||
replica 6a2affca29d0115f: server certificate of the stand CA (ingress) expected no HTTP got no HTTP
|
||||
replica 6a2affca29d0115f: HTTP without TLS expected no HTTP got no HTTP
|
||||
replica 6a2affca29d0115f: allowed identity haproxy expected HTTP 200 TLSv1.3 got HTTP 200 TLSv1.3
|
||||
replica 6a2affca29d0115f: X-Instance-Id = alias from its log expected 6a2affca29d0115f got 6a2affca29d0115f
|
||||
replica 6a2affca29d0115f: 'Rejected TLS client' with mtls-probe expected yes got yes
|
||||
foreign server under alias api: seen by LB, slot not UP expected yes got yes
|
||||
20 requests through LB answered by stand replicas expected yes got yes
|
||||
foreign server: HTTP requests received expected 0 got 0
|
||||
control replica (allowlist with the probe) healthy expected yes got yes
|
||||
control replica: mtls-probe accepted expected HTTP 200 got HTTP 200
|
||||
20 requests through LB: {'200 67c6a50d6592a774': 10, '200 cccacf9b0540977e': 10}
|
||||
replica 67c6a50d6592a774: no client certificate expected no HTTP got no HTTP
|
||||
replica 67c6a50d6592a774: certificate of another CA (SAN haproxy) expected no HTTP got no HTTP
|
||||
replica 67c6a50d6592a774: forbidden identity of the stand CA (mtls-probe) expected no HTTP got no HTTP
|
||||
replica 67c6a50d6592a774: server certificate of the stand CA (ingress) expected no HTTP got no HTTP
|
||||
replica 67c6a50d6592a774: HTTP without TLS expected no HTTP got no HTTP
|
||||
replica 67c6a50d6592a774: allowed identity haproxy expected HTTP 200 TLSv1.3 got HTTP 200 TLSv1.3
|
||||
replica 67c6a50d6592a774: X-Instance-Id = alias from its log expected 67c6a50d6592a774 got 67c6a50d6592a774
|
||||
replica 67c6a50d6592a774: 'Rejected TLS client' with mtls-probe expected yes got yes
|
||||
replica 67c6a50d6592a774: no 'Rejected TLS client' except mtls-probe (others fail at handshake) expected none got none
|
||||
replica cccacf9b0540977e: no client certificate expected no HTTP got no HTTP
|
||||
replica cccacf9b0540977e: certificate of another CA (SAN haproxy) expected no HTTP got no HTTP
|
||||
replica cccacf9b0540977e: forbidden identity of the stand CA (mtls-probe) expected no HTTP got no HTTP
|
||||
replica cccacf9b0540977e: server certificate of the stand CA (ingress) expected no HTTP got no HTTP
|
||||
replica cccacf9b0540977e: HTTP without TLS expected no HTTP got no HTTP
|
||||
replica cccacf9b0540977e: allowed identity haproxy expected HTTP 200 TLSv1.3 got HTTP 200 TLSv1.3
|
||||
replica cccacf9b0540977e: X-Instance-Id = alias from its log expected cccacf9b0540977e got cccacf9b0540977e
|
||||
replica cccacf9b0540977e: 'Rejected TLS client' with mtls-probe expected yes got yes
|
||||
replica cccacf9b0540977e: no 'Rejected TLS client' except mtls-probe (others fail at handshake) expected none got none
|
||||
foreign server under alias api: seen by LB, slot not UP expected yes got yes
|
||||
20 requests through LB answered by stand replicas expected yes got yes
|
||||
foreign server: HTTP requests received expected 0 got 0
|
||||
control replica (allowlist with the probe) healthy expected yes got yes
|
||||
control replica: mtls-probe accepted expected HTTP 200 got HTTP 200
|
||||
PASS: replicas accept only the haproxy identity of the stand CA; a foreign server under the name api gets no requests; the probe tells an allowed identity from a forbidden one
|
||||
cleanup: 2 probe container(s) removed, temporary key directory removed: True
|
||||
exit 0
|
||||
@@ -68,9 +78,11 @@ exit 0
|
||||
соединение до запроса. Без сертификата, с чужим CA и с серверным сертификатом (`ingress`:
|
||||
EKU `serverAuth`, purpose `sslclient` не проходит) отказ — в рукопожатии на стороне сервера:
|
||||
asyncio вне debug его не пишет, алерта клиент до закрытия не прочёл. Запрещённая identity
|
||||
`mtls-probe` рукопожатие проходит, и реплика закрывает соединение в протоколе — это
|
||||
различает запись «Rejected TLS client» с `client_identity: ["mtls-probe"]` в журнале каждой
|
||||
реплики (её нет у прочих случаев);
|
||||
`mtls-probe` рукопожатие проходит, и реплика закрывает соединение в протоколе. Различают их
|
||||
две строки по журналу каждой реплики с начала прогона: запись «Rejected TLS client» с
|
||||
`client_identity: ["mtls-probe"]` есть, а других записей «Rejected TLS client» нет (`none`;
|
||||
иначе в `got` — их `client_identity`). Значит, четыре прочих отказа случились до протокола
|
||||
allowlist, в рукопожатии (verify S1);
|
||||
- HTTP без TLS — ни байта HTTP-ответа;
|
||||
- `haproxy` — 200 по TLS 1.3, `X-Instance-Id` = alias реплики из её журнала;
|
||||
- чужой сервер — контейнер на образе API с алиасом сети `api` и сертификатом `ingress` (SAN
|
||||
@@ -80,7 +92,7 @@ exit 0
|
||||
`API_TLS__ALLOWED_CLIENTS=["haproxy","mtls-probe"]` (без алиаса сети, LB её не видит): та же
|
||||
проба `mtls-probe` получает 200 — проба различает разрешённое и запрещённое, тест не пустой.
|
||||
|
||||
Ключевого материала в выводе нет: `grep -c 'PRIVATE KEY\|BEGIN '` по выводу всех шести прогонов
|
||||
Ключевого материала в выводе нет: `grep -c 'PRIVATE KEY\|BEGIN '` по выводу всех прогонов
|
||||
этой проверки — 0.
|
||||
|
||||
## Расхождение называется — код 1
|
||||
@@ -101,7 +113,7 @@ make: *** [mtls_check] Error 1
|
||||
```
|
||||
|
||||
Затем `make run_docker` вернул штатный allowlist (`API_TLS__ALLOWED_CLIENTS=["haproxy"]` у обеих
|
||||
реплик), и прогон выше — на нём.
|
||||
реплик).
|
||||
|
||||
## Уборка при Ctrl+C
|
||||
|
||||
|
||||
Reference in New Issue
Block a user