fix: use certifi CA bundle to fix TLS handshake with MongoDB Atlas

tlsCAFile=certifi.where() is the correct pymongo parameter to supply the
Mozilla CA bundle, resolving TLSV1_ALERT_INTERNAL_ERROR on both Python
3.11 and 3.14 when connecting to Atlas over TLS.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
vee1e 2026-06-02 13:00:36 +05:30
parent 29a6379370
commit 7dc8a65522
No known key found for this signature in database
GPG key ID: EB498AFC60A7A01A

View file

@ -1,6 +1,7 @@
from motor.motor_asyncio import AsyncIOMotorClient
from pymongo import MongoClient
import os
import certifi
from dotenv import load_dotenv
from urllib.parse import quote_plus
@ -26,7 +27,7 @@ if not MONGODB_URL:
else:
MONGODB_URL = f"mongodb://{user}:{password_enc}@{host}/{DATABASE_NAME}"
async_client = AsyncIOMotorClient(MONGODB_URL)
async_client = AsyncIOMotorClient(MONGODB_URL, tlsCAFile=certifi.where())
database = async_client[DATABASE_NAME]
forms_collection = database.forms