Restore Plex recovery from a changed plex.direct certificate (#180446)

This commit is contained in:
Franck Nijhof
2026-08-29 08:20:30 +00:00
parent 45f9ea3a50
commit 2aa1b43811
2 changed files with 7 additions and 3 deletions
+3 -2
View File
@@ -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"
+4 -1
View File
@@ -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"