Skip to content

Commit

Permalink
Merge pull request #480 from zabuldon/dev
Browse files Browse the repository at this point in the history
fix: UnboundLocalError when both websession and api_proxy_cert provided
  • Loading branch information
alandtse authored Nov 26, 2024
2 parents 3ba92f1 + 2cb965a commit c3eeeb8
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions teslajsonpy/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,14 @@ def __init__(
ssl_context = ssl.create_default_context()
websession = httpx.AsyncClient(timeout=60, verify=ssl_context)

if api_proxy_cert:
# Loading custom SSL certificate for proxy does blocking I/O.
# It is recommended to instead pass an httpx.AsyncClient that
# already has an SSL context with the custom certificate loaded.
try:
ssl_context.load_verify_locations(api_proxy_cert)
except (FileNotFoundError, ssl.SSLError):
_LOGGER.warning("Unable to load custom SSL certificate from %s", api_proxy_cert)
if api_proxy_cert:
# Loading custom SSL certificate for proxy does blocking I/O.
# It is recommended to instead pass an httpx.AsyncClient that
# already has an SSL context with the custom certificate loaded.
try:
ssl_context.load_verify_locations(api_proxy_cert)
except (FileNotFoundError, ssl.SSLError):
_LOGGER.warning("Unable to load custom SSL certificate from %s", api_proxy_cert)

self.__connection = Connection(
websession=websession,
Expand Down

0 comments on commit c3eeeb8

Please sign in to comment.