Fix ssl DeprecationWarnings (#97623)

This commit is contained in:
Marc Mueller 2023-08-03 09:11:41 +02:00 committed by GitHub
parent 3c2cebea72
commit ad0873549d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 9 deletions

View File

@ -8,7 +8,7 @@ from datetime import timedelta
from functools import wraps from functools import wraps
from http import HTTPStatus from http import HTTPStatus
import logging import logging
from ssl import SSLContext import ssl
from typing import Any, Concatenate, ParamSpec, TypeVar, cast from typing import Any, Concatenate, ParamSpec, TypeVar, cast
from aiowebostv import WebOsClient, WebOsTvPairError from aiowebostv import WebOsClient, WebOsTvPairError
@ -476,7 +476,7 @@ class LgWebOSMediaPlayerEntity(RestoreEntity, MediaPlayerEntity):
content = None content = None
ssl_context = None ssl_context = None
if url.startswith("https"): if url.startswith("https"):
ssl_context = SSLContext() ssl_context = ssl.SSLContext(protocol=ssl.PROTOCOL_TLS_CLIENT)
websession = async_get_clientsession(self.hass) websession = async_get_clientsession(self.hass)
with suppress(asyncio.TimeoutError): with suppress(asyncio.TimeoutError):

View File

@ -127,14 +127,9 @@ def server_context_modern() -> ssl.SSLContext:
Modern guidelines are followed. Modern guidelines are followed.
""" """
context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER) context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
context.minimum_version = ssl.TLSVersion.TLSv1_2
context.options |= ( context.options |= ssl.OP_CIPHER_SERVER_PREFERENCE
ssl.OP_NO_SSLv2
| ssl.OP_NO_SSLv3
| ssl.OP_NO_TLSv1
| ssl.OP_NO_TLSv1_1
| ssl.OP_CIPHER_SERVER_PREFERENCE
)
if hasattr(ssl, "OP_NO_COMPRESSION"): if hasattr(ssl, "OP_NO_COMPRESSION"):
context.options |= ssl.OP_NO_COMPRESSION context.options |= ssl.OP_NO_COMPRESSION