Skip to content

Commit

Permalink
Pass default SSLContext instances to Octoprint custom HTTP sessions (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
vexofp authored and frenck committed Jan 30, 2024
1 parent 4c4dc6a commit 8c6547f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion homeassistant/components/octoprint/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.typing import ConfigType
from homeassistant.util import slugify as util_slugify
from homeassistant.util.ssl import get_default_context, get_default_no_verify_context

from .const import DOMAIN
from .coordinator import OctoprintDataUpdateCoordinator
Expand Down Expand Up @@ -159,7 +160,9 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:

connector = aiohttp.TCPConnector(
force_close=True,
ssl=False if not entry.data[CONF_VERIFY_SSL] else None,
ssl=get_default_no_verify_context()
if not entry.data[CONF_VERIFY_SSL]
else get_default_context(),
)
session = aiohttp.ClientSession(connector=connector)

Expand Down
5 changes: 4 additions & 1 deletion homeassistant/components/octoprint/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
)
from homeassistant.data_entry_flow import FlowResult
import homeassistant.helpers.config_validation as cv
from homeassistant.util.ssl import get_default_context, get_default_no_verify_context

from .const import DOMAIN

Expand Down Expand Up @@ -264,7 +265,9 @@ def _get_octoprint_client(self, user_input: dict) -> OctoprintClient:

connector = aiohttp.TCPConnector(
force_close=True,
ssl=False if not verify_ssl else None,
ssl=get_default_no_verify_context()
if not verify_ssl
else get_default_context(),
)
session = aiohttp.ClientSession(connector=connector)
self._sessions.append(session)
Expand Down

0 comments on commit 8c6547f

Please sign in to comment.