Files
mtusi2026lab7/app/tlsutil.py
T
dawudukandCursor fb566d874c Перевести пароли на Argon2id и читать секреты через AppRole.
Лимит входа общий для реплик, размер тела ограничен, исходящие клиенты проверяют TLS, если задан CA.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-26 19:40:28 +03:00

23 lines
715 B
Python

import ssl
from app import config
def server_context() -> ssl.SSLContext | None:
"""Trust store for outbound TLS. None means the dependency is still plaintext."""
if not config.TLS_CA_FILE:
return None
context = ssl.create_default_context(cafile=config.TLS_CA_FILE)
context.check_hostname = True
context.verify_mode = ssl.CERT_REQUIRED
context.minimum_version = ssl.TLSVersion.TLSv1_2
if config.TLS_CERT_FILE and config.TLS_KEY_FILE:
context.load_cert_chain(config.TLS_CERT_FILE, config.TLS_KEY_FILE)
return context
def https_verify(endpoint: str):
if endpoint.startswith("https://") and config.TLS_CA_FILE:
return config.TLS_CA_FILE
return True