Закрыть внешний вход TLS и выдавать секреты через OpenBao.

LB ходит в API только с клиентским сертификатом нужной identity, остальные связи проверяют серверный сертификат, root token в приложение не попадает.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-11-26 19:48:38 +03:00
co-authored by Cursor
parent fb566d874c
commit 9b501b2020
33 changed files with 1243 additions and 221 deletions
+7 -3
View File
@@ -80,17 +80,21 @@ async def _handle(client_reader: asyncio.StreamReader, client_writer: asyncio.St
def _context() -> ssl.SSLContext:
cert = config.TLS_SERVER_CERT_FILE or config.TLS_CERT_FILE
key = config.TLS_SERVER_KEY_FILE or config.TLS_KEY_FILE
context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
context.minimum_version = ssl.TLSVersion.TLSv1_2
context.load_cert_chain(config.TLS_CERT_FILE, config.TLS_KEY_FILE)
context.load_cert_chain(cert, key)
context.load_verify_locations(config.TLS_CA_FILE)
context.verify_mode = ssl.CERT_REQUIRED
return context
async def serve() -> None:
if not (config.TLS_CERT_FILE and config.TLS_KEY_FILE and config.TLS_CA_FILE):
raise SystemExit("TLS_CERT_FILE, TLS_KEY_FILE and TLS_CA_FILE are required")
cert = config.TLS_SERVER_CERT_FILE or config.TLS_CERT_FILE
key = config.TLS_SERVER_KEY_FILE or config.TLS_KEY_FILE
if not (cert and key and config.TLS_CA_FILE and config.MTLS_ALLOW_FILE):
raise SystemExit("server certificate, CA and MTLS_ALLOW_FILE are required")
server = await asyncio.start_server(_handle, "0.0.0.0", config.MTLS_PORT, ssl=_context())
logger.info("mTLS proxy listening on %s", config.MTLS_PORT)
async with server: