Skip to content

Commit

Permalink
fix: fix api proxy cert blocking the event loop (#1030)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco authored Aug 11, 2024
1 parent ac9eb97 commit 74f2986
Showing 1 changed file with 7 additions and 5 deletions.
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,

Check failure

Code scanning / CodeQL

Clear-text logging of sensitive information High

This expression logs
sensitive data (certificate)
as clear text.
)

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),
api_proxy_url=config.get(CONF_API_PROXY_URL),
client_id=config.get(CONF_CLIENT_ID),
)
Expand Down

0 comments on commit 74f2986

Please sign in to comment.