Checkpoint before follow-up message

Co-authored-by: mathieumoran1 <[email protected]>
This commit is contained in:
Cursor Agent
2025-12-22 09:06:53 +00:00
co-authored by mathieumoran1
parent 7cffe9db58
commit 872d56213e
2 changed files with 15 additions and 0 deletions
+15
View File
@@ -1,6 +1,7 @@
import mimetypes import mimetypes
import os import os
import posixpath import posixpath
import ssl
from functools import lru_cache from functools import lru_cache
from datetime import datetime, timezone from datetime import datetime, timezone
from pathlib import Path from pathlib import Path
@@ -172,6 +173,19 @@ def _mongo_client() -> MongoClient:
# If certifi isn't available, fall back to system trust. # If certifi isn't available, fall back to system trust.
pass pass
# Some hosts / middleboxes break TLS 1.3 handshakes to Atlas and produce
# `TLSV1_ALERT_INTERNAL_ERROR`. Forcing TLS 1.2 can fix it.
if _env_str("MONGO_TLS_FORCE_TLS12", "0") in ("1", "true", "yes", "on"):
cafile = kwargs.pop("tlsCAFile", None)
ctx = ssl.create_default_context(cafile=cafile)
try:
ctx.minimum_version = ssl.TLSVersion.TLSv1_2
ctx.maximum_version = ssl.TLSVersion.TLSv1_2
except Exception:
# Older Python/OpenSSL may not support TLSVersion fields.
pass
kwargs["ssl_context"] = ctx
# Optional escape hatch (NOT recommended): allow invalid certs for debugging only. # Optional escape hatch (NOT recommended): allow invalid certs for debugging only.
if _env_str("MONGO_TLS_INSECURE", "0") in ("1", "true", "yes", "on"): if _env_str("MONGO_TLS_INSECURE", "0") in ("1", "true", "yes", "on"):
kwargs["tlsAllowInvalidCertificates"] = True kwargs["tlsAllowInvalidCertificates"] = True
@@ -337,6 +351,7 @@ def healthz():
"time": datetime.now(timezone.utc).isoformat(), "time": datetime.now(timezone.utc).isoformat(),
"video_files_dir": str(_video_files_dir()), "video_files_dir": str(_video_files_dir()),
"mongo_db_name": _mongo_db_name() or None, "mongo_db_name": _mongo_db_name() or None,
"openssl": ssl.OPENSSL_VERSION,
} }