PYTHON-5414 Fix "module service_identity has no attribute SICertificateError" when using pyopenssl (#2382)

This commit is contained in:
Maarten Sijm 2025-06-13 01:45:18 +02:00 committed by GitHub
parent 54846cd110
commit c2aefc2eda
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -420,9 +420,9 @@ class SSLContext:
pyopenssl.verify_ip_address(ssl_conn, server_hostname)
else:
pyopenssl.verify_hostname(ssl_conn, server_hostname)
except ( # type:ignore[misc]
service_identity.SICertificateError,
service_identity.SIVerificationError,
except (
service_identity.CertificateError,
service_identity.VerificationError,
) as exc:
raise _CertificateError(str(exc)) from None
return ssl_conn