forked from mtusi2026/mtusi2026lab7
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:
@@ -28,6 +28,20 @@ if __name__ == "__main__":
|
||||
)
|
||||
sys.exit(2)
|
||||
|
||||
# TLS к хранилищам (change storage-tls, design, решение 5): CA стенда и
|
||||
# имена PostgreSQL и S3 — до первого подключения; поля без значений
|
||||
from src.config import settings
|
||||
from src.infra.tls import WORKER_STORAGES, client_tls_problems
|
||||
|
||||
if problems := client_tls_problems(settings, WORKER_STORAGES):
|
||||
early_stop.write_record(
|
||||
"Invalid client TLS settings",
|
||||
level="error",
|
||||
module="worker",
|
||||
fields=problems,
|
||||
)
|
||||
sys.exit(2)
|
||||
|
||||
code = main()
|
||||
# клиенты закрыты, «Stopped worker» записан. Финализация незакрытых за срок
|
||||
# клиентов не должна тянуть остановку: именно os._exit укладывается в срок
|
||||
|
||||
+7
-2
@@ -95,10 +95,15 @@ async def run() -> int:
|
||||
telemetry_enabled = telemetry.start_process_telemetry(
|
||||
TELEMETRY_SERVICE_WORKER,
|
||||
)
|
||||
engine = create_engine(settings.database)
|
||||
ca_file = settings.client_tls.ca_file
|
||||
engine = create_engine(settings.database, ca_file=ca_file)
|
||||
telemetry.instrument_engine(engine)
|
||||
session_factory = create_session_factory(engine)
|
||||
storage = create_object_storage(settings.s3, namespace=namespace)
|
||||
storage = create_object_storage(
|
||||
settings.s3,
|
||||
namespace=namespace,
|
||||
ca_file=ca_file,
|
||||
)
|
||||
|
||||
make_service = service_factory(
|
||||
session_factory,
|
||||
|
||||
Reference in New Issue
Block a user