mirror of
https://github.com/home-assistant/core.git
synced 2026-09-24 07:25:52 -05:00
Restore Plex recovery from a changed plex.direct certificate (#180446)
This commit is contained in:
@@ -191,8 +191,9 @@ class PlexServer:
|
||||
error = error.__context__
|
||||
if isinstance(error, ssl.SSLCertVerificationError):
|
||||
domain = urlparse(self._url).netloc.split(":")[0]
|
||||
if domain.endswith("plex.direct") and error.args[0].startswith(
|
||||
f"hostname '{domain}' doesn't match"
|
||||
# OpenSSL's own wording for X509_V_ERR_HOSTNAME_MISMATCH
|
||||
if domain.endswith("plex.direct") and "Hostname mismatch" in str(
|
||||
error
|
||||
):
|
||||
_LOGGER.warning(
|
||||
"Plex SSL certificate's hostname changed, updating"
|
||||
|
||||
@@ -210,8 +210,11 @@ async def test_setup_when_certificate_changed(
|
||||
"""Mock the exception showing a mismatched hostname."""
|
||||
|
||||
def __init__(self) -> None: # pylint: disable=super-init-not-called
|
||||
# Shaped the way it is really raised: OSError args of (errno, message)
|
||||
self.__context__ = ssl.SSLCertVerificationError(
|
||||
f"hostname '{old_domain}' doesn't match"
|
||||
1,
|
||||
"[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed:"
|
||||
f" Hostname mismatch, certificate is not valid for '{old_domain}'.",
|
||||
)
|
||||
|
||||
old_domain = "1-2-3-4.1111111111ffffff1111111111ffffff.plex.direct"
|
||||
|
||||
Reference in New Issue
Block a user