mirror of
https://github.com/home-assistant/core.git
synced 2025-07-18 18:57:06 +00:00
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:
parent
5b80eb4c3d
commit
4fb127e5af
@ -2,13 +2,13 @@
|
|||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
import datetime
|
import datetime
|
||||||
from functools import cache
|
|
||||||
import socket
|
import socket
|
||||||
import ssl
|
import ssl
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.util import dt as dt_util
|
from homeassistant.util import dt as dt_util
|
||||||
|
from homeassistant.util.ssl import get_default_context
|
||||||
|
|
||||||
from .const import TIMEOUT
|
from .const import TIMEOUT
|
||||||
from .errors import (
|
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(
|
async def async_get_cert(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
host: str,
|
host: str,
|
||||||
@ -36,7 +30,7 @@ async def async_get_cert(
|
|||||||
asyncio.Protocol,
|
asyncio.Protocol,
|
||||||
host,
|
host,
|
||||||
port,
|
port,
|
||||||
ssl=_get_default_ssl_context(),
|
ssl=get_default_context(),
|
||||||
happy_eyeballs_delay=0.25,
|
happy_eyeballs_delay=0.25,
|
||||||
server_hostname=host,
|
server_hostname=host,
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user