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

Using get_default_context() for ssl context to avoid blocking call #791

Merged
merged 1 commit into from
Oct 4, 2024
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
14 changes: 11 additions & 3 deletions custom_components/smartthinq_sensors/wideq/core_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,20 @@ def _oauth_info_from_result(result_info: dict) -> dict:
return result


def lg_client_session() -> aiohttp.ClientSession:
"""Create an aiohttp client session to use with LG ThinQ."""
def _create_lg_ssl_context() -> ssl.SSLContext:
"""Create a SSL context for LG ThinQ."""
context = ssl.create_default_context()
context.set_ciphers(_LG_SSL_CIPHERS)
return context


_SSL_CONTEXT = _create_lg_ssl_context()


def lg_client_session() -> aiohttp.ClientSession:
"""Create an aiohttp client session to use with LG ThinQ."""
connector = aiohttp.TCPConnector(
enable_cleanup_closed=ENABLE_CLEANUP_CLOSED, ssl_context=context
enable_cleanup_closed=ENABLE_CLEANUP_CLOSED, ssl_context=_SSL_CONTEXT
)
return aiohttp.ClientSession(connector=connector)

Expand Down
Loading