From d4bfb522ac0992b73dc15f1f6ecfe6d772c74fdc Mon Sep 17 00:00:00 2001 From: dvirlabs <114520947+dvirlabs@users.noreply.github.com> Date: Thu, 14 May 2026 16:06:38 +0300 Subject: [PATCH] Fix SSL handshake: simplify SSL context config for Meta API compatibility --- backend/whatsapp.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/backend/whatsapp.py b/backend/whatsapp.py index 293e157..6e1e61a 100644 --- a/backend/whatsapp.py +++ b/backend/whatsapp.py @@ -18,13 +18,16 @@ logger = logging.getLogger(__name__) async def create_http_client() -> httpx.AsyncClient: """ Create an httpx client with proper certificate verification. - Uses certifi for CA bundle and creates proper SSL context for handshake. + Uses certifi for CA bundle with minimal SSL configuration for compatibility. """ - # Create SSL context with proper certificate verification + # Create SSL context with certifi's CA bundle ssl_context = ssl.create_default_context(cafile=certifi.where()) - ssl_context.minimum_version = ssl.TLSVersion.TLSv1_2 - ssl_context.maximum_version = ssl.TLSVersion.TLSv1_3 - ssl_context.options |= ssl.OP_NO_COMPRESSION + # Ensure TLS 1.2+ but allow server to negotiate the version + try: + ssl_context.minimum_version = ssl.TLSVersion.TLSv1_2 + except AttributeError: + # Older Python versions - just use defaults + pass return httpx.AsyncClient( verify=ssl_context,