From c2aefc2edab2c34d10e34d69793431b0d6800d24 Mon Sep 17 00:00:00 2001 From: Maarten Sijm <9739541+mpsijm@users.noreply.github.com> Date: Fri, 13 Jun 2025 01:45:18 +0200 Subject: [PATCH] PYTHON-5414 Fix "module service_identity has no attribute SICertificateError" when using pyopenssl (#2382) --- pymongo/pyopenssl_context.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pymongo/pyopenssl_context.py b/pymongo/pyopenssl_context.py index 0d4f27cf5..08fe99c88 100644 --- a/pymongo/pyopenssl_context.py +++ b/pymongo/pyopenssl_context.py @@ -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