Skip to content

Commit 039bf06

Browse files
committed
remove cryptography workarounds
1 parent 929d362 commit 039bf06

File tree

3 files changed

+4
-13
lines changed

3 files changed

+4
-13
lines changed

pymongo/ocsp_support.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -347,13 +347,8 @@ def _ocsp_callback(conn: Connection, ocsp_bytes: bytes, user_data: Optional[_Cal
347347
_LOGGER.debug("No peer cert?")
348348
return False
349349
cert = pycert.to_cryptography()
350-
# Use the verified chain when available (pyopenssl>=20.0).
351-
if hasattr(conn, "get_verified_chain"):
352-
pychain = conn.get_verified_chain()
353-
trusted_ca_certs = None
354-
else:
355-
pychain = conn.get_peer_cert_chain()
356-
trusted_ca_certs = user_data.trusted_ca_certs
350+
pychain = conn.get_verified_chain()
351+
trusted_ca_certs = None
357352
if not pychain:
358353
_LOGGER.debug("No peer cert chain?")
359354
return False

pymongo/pyopenssl_context.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
from pymongo.errors import ConfigurationError as _ConfigurationError
3636
from pymongo.errors import _CertificateError # type:ignore[attr-defined]
3737
from pymongo.ocsp_cache import _OCSPCache
38-
from pymongo.ocsp_support import _load_trusted_ca_certs, _ocsp_callback
38+
from pymongo.ocsp_support import _ocsp_callback
3939
from pymongo.socket_checker import SocketChecker as _SocketChecker
4040
from pymongo.socket_checker import _errno_from_exception
4141
from pymongo.write_concern import validate_boolean
@@ -322,10 +322,6 @@ def load_verify_locations(
322322
ssl.CERT_NONE.
323323
"""
324324
self._ctx.load_verify_locations(cafile, capath)
325-
# Manually load the CA certs when get_verified_chain is not available (pyopenssl<20).
326-
if not hasattr(_SSL.Connection, "get_verified_chain"):
327-
assert cafile is not None
328-
self._callback_data.trusted_ca_certs = _load_trusted_ca_certs(cafile)
329325

330326
def _load_certifi(self) -> None:
331327
"""Attempt to load CA certs from certifi."""

requirements/ocsp.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@
88
certifi>=2022.5.18.1;os.name=='nt' or sys_platform=='darwin'
99
pyopenssl>=22.0
1010
requests>2.23,<3.0.0
11-
cryptography>=2.5
11+
cryptography>=38.0
1212
service_identity>=18.1.0

0 commit comments

Comments
 (0)