Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions custom_components/tesla_custom/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,17 @@ async def async_setup_entry(hass, config_entry):
# Because users can have multiple accounts, we always
# create a new session so they have separate cookies

if config.get(CONF_API_PROXY_CERT):
if api_proxy_cert := config.get(CONF_API_PROXY_CERT):
try:
SSL_CONTEXT.load_verify_locations(config[CONF_API_PROXY_CERT])
_LOGGER.debug("Trusting CA: %s", SSL_CONTEXT.get_ca_certs()[-1])
await hass.async_add_executor_job(
SSL_CONTEXT.load_verify_locations, api_proxy_cert
)
if _LOGGER.isEnabledFor(logging.DEBUG):
_LOGGER.debug("Trusting CA: %s", SSL_CONTEXT.get_ca_certs()[-1])
except (FileNotFoundError, ssl.SSLError):
_LOGGER.warning(
"Unable to load custom SSL certificate from %s",
config[CONF_API_PROXY_CERT],
api_proxy_cert,
)

async_client = httpx.AsyncClient(
Expand Down Expand Up @@ -181,7 +184,6 @@ async def async_setup_entry(hass, config_entry):
polling_policy=config_entry.options.get(
CONF_POLLING_POLICY, DEFAULT_POLLING_POLICY
),
api_proxy_cert=config.get(CONF_API_PROXY_CERT),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No point in passing this if we already loaded it and we pass the AsyncClient

api_proxy_url=config.get(CONF_API_PROXY_URL),
client_id=config.get(CONF_CLIENT_ID),
)
Expand Down