Avoid creating another ssl context in cert_expiry (#113467)

Creating an ssl context does blocking I/O as it has to
read the certs from disk
This commit is contained in:
J. Nick Koston 2024-03-14 13:58:11 -10:00 committed by GitHub
parent 5b80eb4c3d
commit 4fb127e5af
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2,13 +2,13 @@
import asyncio
import datetime
from functools import cache
import socket
import ssl
from typing import Any
from homeassistant.core import HomeAssistant
from homeassistant.util import dt as dt_util
from homeassistant.util.ssl import get_default_context
from .const import TIMEOUT
from .errors import (
@ -19,12 +19,6 @@ from .errors import (
)
@cache
def _get_default_ssl_context() -> ssl.SSLContext:
"""Return the default SSL context."""
return ssl.create_default_context()
async def async_get_cert(
hass: HomeAssistant,
host: str,
@ -36,7 +30,7 @@ async def async_get_cert(
asyncio.Protocol,
host,
port,
ssl=_get_default_ssl_context(),
ssl=get_default_context(),
happy_eyeballs_delay=0.25,
server_hostname=host,
)