11import asyncio
22import hashlib
33import json
4+ import ssl
45from typing import Any , Callable , Dict , List , Optional
56
7+ import certifi
68import httpx
79from httpx_sse import aconnect_sse
810
@@ -19,7 +21,7 @@ def __init__(self, api: API, devices: Devices):
1921 self ._api = api
2022 self ._devices = devices
2123 self .mapper : GraphqlValueMapper = GraphqlValueMapper ()
22-
24+ self . ssl_context = ssl . create_default_context ( cafile = certifi . where ())
2325 self .subscriptions : List [Optional [asyncio .Task ]] = [None ]
2426
2527 async def async_init (self ) -> None :
@@ -548,7 +550,7 @@ async def call_get_location_query(self, location_hilo_id: str) -> None:
548550 "variables" : {"locationHiloId" : location_hilo_id },
549551 }
550552
551- async with httpx .AsyncClient (http2 = True ) as client :
553+ async with httpx .AsyncClient (http2 = True , verify = self . ssl_context ) as client :
552554 try :
553555 response = await client .post (url , json = payload , headers = headers )
554556 response .raise_for_status ()
@@ -634,7 +636,9 @@ async def _listen_to_sse(
634636
635637 retry_with_full_query = False
636638
637- async with httpx .AsyncClient (http2 = True , timeout = None ) as client :
639+ async with httpx .AsyncClient (
640+ http2 = True , timeout = None , verify = self .ssl_context
641+ ) as client :
638642 async with aconnect_sse (
639643 client , "POST" , url , json = payload , headers = headers
640644 ) as event_source :
0 commit comments