diff --git a/backend/whatsapp.py b/backend/whatsapp.py index f89f05f..9dcc67a 100644 --- a/backend/whatsapp.py +++ b/backend/whatsapp.py @@ -5,7 +5,6 @@ Handles sending WhatsApp messages via Meta's API import os import httpx import certifi -import ssl import re import logging from typing import Optional @@ -18,19 +17,10 @@ logger = logging.getLogger(__name__) async def create_http_client() -> httpx.AsyncClient: """ Create an httpx client with proper certificate verification. - Uses certifi for CA bundle with minimal SSL configuration for compatibility. + Uses certifi for CA bundle with httpx's built-in SSL handling for best compatibility. """ - # Create SSL context with certifi's CA bundle - ssl_context = ssl.create_default_context(cafile=certifi.where()) - # 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, + verify=certifi.where(), timeout=httpx.Timeout(30.0, connect=10.0), http2=False, limits=httpx.Limits(max_keepalive_connections=5, max_connections=10)