Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass default SSLContext instances to Octoprint custom HTTP sessions #105351

Merged
merged 1 commit into from Jan 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion homeassistant/components/octoprint/__init__.py
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
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