forked from mtusi2026/mtusi2026lab7
Перевести пароли на Argon2id и читать секреты через AppRole.
Лимит входа общий для реплик, размер тела ограничен, исходящие клиенты проверяют TLS, если задан CA. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
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
|
||||
Reference in New Issue
Block a user