feat: require TLS to PostgreSQL, Valkey and S3

Storage servers accept only TLS 1.3 (pg_hba hostssl / hostnossl reject,
Valkey port 0, S3 gateway HTTPS only) with stand identities postgres,
valkey and s3. Clients trust only the stand CA from [client_tls] ca_file
and check the host name; no switch to disable verification. Processes
exit with code 2 without a CA or with an IP storage address. Temporary
stands, CI and bench/ run on TLS storages; make storage_tls_check adds
negative checks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-18 21:17:49 +03:00
co-authored by Claude Opus 5.5
parent 25f5d981c0
commit 8bca5543fd
56 changed files with 2562 additions and 176 deletions
+9
View File
@@ -8,7 +8,16 @@
# ingress: localhost — внешние клиенты, ingress — алиас LB в сети стенда для
# клиентов внутри неё (job CI, k6 стенда bench/; change https-tooling).
#
# postgres, valkey, s3 (change storage-tls, design, решение 2): серверы
# хранилищ; первое имя SAN = POSTGRES_HOST / VALKEY_HOST / S3_HOST из .env
# (клиенты в сети стенда проверяют имя, по которому подключаются; смена
# *_HOST — та же правка строки), localhost — порт на хосте для консоли и
# проверок с хоста.
#
# имя профиль SAN форма
haproxy client haproxy bundle
api server api split
ingress server localhost,ingress bundle
postgres server postgres,localhost split
valkey server valkey,localhost split
s3 server s3,localhost split
+19
View File
@@ -0,0 +1,19 @@
# pg_hba.conf стенда (change storage-tls, design, решения 3 и 7; спек
# transport-security, «TLS к хранилищам стенда»). Сервису postgres — bind
# read-only (-c hba_file=/etc/postgresql/pg_hba.conf), в CI — configs.
#
# Граница открытого текста — только сокет внутри контейнера PostgreSQL: его
# видят лишь процессы контейнера (временный сервер инициализации образа,
# docker compose exec … psql оператора, hook стенда отказов, run_isolated.py,
# оркестратор bench/). Пути из сети к сокету нет.
#
# Сеть (сеть compose и порт 127.0.0.1 хоста) — только TLS (не ниже 1.3,
# ssl_min_protocol_version в command сервиса) и пароль SCRAM; соединение без
# TLS отвергается до аутентификации («pg_hba.conf rejects connection … no encryption»).
# Сертификата клиента сервер не требует: идентичность клиента — пароль роли
# (раздельные роли — change storage-roles).
#
# TYPE DATABASE USER ADDRESS METHOD
local all all trust
hostssl all all all scram-sha-256
hostnossl all all all reject
+14 -2
View File
@@ -47,7 +47,16 @@ S3_PORT=${S3_PORT:?S3_PORT is not set}
LIST_PREFIX=${S3_CLEANER_LIST_PREFIX:-}
MASTER=127.0.0.1:9333
S3=http://127.0.0.1:${S3_PORT}
# API S3 — только HTTPS с проверкой CA стенда и имени шлюза (change
# storage-tls, design, решение 7): имя S3_HOST (SAN identity s3), адрес —
# loopback сетевого пространства s3 (--resolve); master — служебный, loopback
S3_HOST=${S3_HOST:-s3}
S3_CA_FILE=${S3_CA_FILE:-/run/secrets/ca.crt}
S3=https://${S3_HOST}:${S3_PORT}
[ -r "$S3_CA_FILE" ] || {
echo "s3-bootstrap: FAILED: CA certificate is not readable" >&2
exit 1
}
API_USER=api
API_POLICY=api-objects
CLEANER_USER=cleaner
@@ -131,6 +140,7 @@ signed_by() {
cred=$1
shift
curl -s -o "$BODY" -w '%{http_code}' --max-time 5 -K "$cred" \
--cacert "$S3_CA_FILE" --resolve "${S3_HOST}:${S3_PORT}:127.0.0.1" \
--aws-sigv4 "aws:amz:${REGION}:s3" "$@" || echo 000
}
@@ -151,7 +161,9 @@ worker_signed() {
# анонимный запрос: печатает код ответа
anon() {
curl -s -o "$BODY" -w '%{http_code}' --max-time 5 "$@" || echo 000
curl -s -o "$BODY" -w '%{http_code}' --max-time 5 \
--cacert "$S3_CA_FILE" --resolve "${S3_HOST}:${S3_PORT}:127.0.0.1" \
"$@" || echo 000
}
FAILED_CHECKS=0
+11
View File
@@ -13,3 +13,14 @@ appendonly no
# без пароля сервер не примет соединения извне контейнера
protected-mode yes
# только TLS (change storage-tls, design, решение 3): command задаёт
# --port 0 (слушателя без TLS нет) и --tls-port. Сертификат и ключ identity
# valkey — secrets сервиса; CA сервер требует при включённом TLS, но
# сертификата клиента не проверяет (идентичность — пароль, ACL — change
# storage-roles). Клиенты стенда договариваются только о TLS 1.3
tls-cert-file /run/secrets/valkey.crt
tls-key-file /run/secrets/valkey.key
tls-ca-cert-file /run/secrets/ca.crt
tls-auth-clients no
tls-protocols "TLSv1.3"