Don't check SSL certificate retrieving webos image (#104014)

I didn't test this in HA, but I did test this in a Python REPL, manually
querying my TV. The old method for ignoring SSL certificate validation
doesn't work at all. This method does and is supported by the aiohttp
documentation.

https://docs.aiohttp.org/en/stable/client_reference.html

Fixes #102109
This commit is contained in:
Ellis Michael 2024-01-29 11:41:53 -08:00 committed by GitHub
parent a9fe63ed90
commit a289ab9044
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -8,7 +8,6 @@ from datetime import timedelta
from functools import wraps from functools import wraps
from http import HTTPStatus from http import HTTPStatus
import logging import logging
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
@ -473,14 +472,11 @@ class LgWebOSMediaPlayerEntity(RestoreEntity, MediaPlayerEntity):
SSLContext to bypass validation errors if url starts with https. SSLContext to bypass validation errors if url starts with https.
""" """
content = None content = None
ssl_context = None
if url.startswith("https"):
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):
async with asyncio.timeout(10): async with asyncio.timeout(10):
response = await websession.get(url, ssl=ssl_context) response = await websession.get(url, ssl=False)
if response.status == HTTPStatus.OK: if response.status == HTTPStatus.OK:
content = await response.read() content = await response.read()