This commit is contained in:
parent
5c4bb0d3fa
commit
a70a201222
@ -5,6 +5,7 @@ Handles sending WhatsApp messages via Meta's API
|
|||||||
import os
|
import os
|
||||||
import httpx
|
import httpx
|
||||||
import certifi
|
import certifi
|
||||||
|
import ssl
|
||||||
import re
|
import re
|
||||||
import logging
|
import logging
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
@ -17,10 +18,16 @@ logger = logging.getLogger(__name__)
|
|||||||
async def create_http_client() -> httpx.AsyncClient:
|
async def create_http_client() -> httpx.AsyncClient:
|
||||||
"""
|
"""
|
||||||
Create an httpx client with proper certificate verification.
|
Create an httpx client with proper certificate verification.
|
||||||
Uses certifi for CA bundle - simple and reliable.
|
Uses certifi for CA bundle and creates proper SSL context for handshake.
|
||||||
"""
|
"""
|
||||||
|
# Create SSL context with proper certificate verification
|
||||||
|
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
|
||||||
|
|
||||||
return httpx.AsyncClient(
|
return httpx.AsyncClient(
|
||||||
verify=certifi.where(),
|
verify=ssl_context,
|
||||||
timeout=httpx.Timeout(30.0, connect=10.0),
|
timeout=httpx.Timeout(30.0, connect=10.0),
|
||||||
http2=False,
|
http2=False,
|
||||||
limits=httpx.Limits(max_keepalive_connections=5, max_connections=10)
|
limits=httpx.Limits(max_keepalive_connections=5, max_connections=10)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user