Fix SSL handshake: simplify SSL context config for Meta API compatibility
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
dvirlabs 2026-05-14 16:06:38 +03:00
parent 66e5f3bf70
commit d4bfb522ac

View File

@ -18,13 +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 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 = ssl.create_default_context(cafile=certifi.where())
ssl_context.minimum_version = ssl.TLSVersion.TLSv1_2 # Ensure TLS 1.2+ but allow server to negotiate the version
ssl_context.maximum_version = ssl.TLSVersion.TLSv1_3 try:
ssl_context.options |= ssl.OP_NO_COMPRESSION ssl_context.minimum_version = ssl.TLSVersion.TLSv1_2
except AttributeError:
# Older Python versions - just use defaults
pass
return httpx.AsyncClient( return httpx.AsyncClient(
verify=ssl_context, verify=ssl_context,