Skip to content

Commit 3c8b783

Browse files
committed
PYTHON-2866 Setting tlsDisableOCSPEndpointCheck=false must enable OCSP endpoint check
(cherry picked from commit fe1d19d)
1 parent 6a18027 commit 3c8b783

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

pymongo/common.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -630,12 +630,14 @@ def validate_tzinfo(dummy, value):
630630
'tls': validate_boolean_or_string,
631631
'tlsallowinvalidcertificates': validate_allow_invalid_certs,
632632
'ssl_cert_reqs': validate_cert_reqs,
633+
# Normalized to ssl_match_hostname which is the logical inverse of tlsallowinvalidhostnames
633634
'tlsallowinvalidhostnames': lambda *x: not validate_boolean_or_string(*x),
634635
'ssl_match_hostname': validate_boolean_or_string,
635636
'tlscafile': validate_readable,
636637
'tlscertificatekeyfile': validate_readable,
637638
'tlscertificatekeyfilepassword': validate_string_or_none,
638-
'tlsdisableocspendpointcheck': validate_boolean_or_string,
639+
# Normalized to ssl_check_ocsp_endpoint which is the logical inverse of tlsdisableocspendpointcheck
640+
'tlsdisableocspendpointcheck': lambda *x: not validate_boolean_or_string(*x),
639641
'tlsinsecure': validate_boolean_or_string,
640642
'w': validate_non_negative_int_or_basestring,
641643
'wtimeoutms': validate_non_negative_integer,

test/test_uri_parser.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,16 @@ def test_tlsinsecure_legacy_conflict(self):
479479
with self.assertRaises(InvalidURI):
480480
parse_uri(uri, validate=False, warn=False, normalize=False)
481481

482+
def test_tlsDisableOCSPEndpointCheck(self):
483+
# check that tlsDisableOCSPEndpointCheck is handled correctly.
484+
uri = "mongodb://example.com/?tlsDisableOCSPEndpointCheck=true"
485+
res = {'ssl_check_ocsp_endpoint': False}
486+
self.assertEqual(res, parse_uri(uri)["options"])
487+
488+
uri = "mongodb://example.com/?tlsDisableOCSPEndpointCheck=false"
489+
res = {'ssl_check_ocsp_endpoint': True}
490+
self.assertEqual(res, parse_uri(uri)["options"])
491+
482492
def test_normalize_options(self):
483493
# check that options are converted to their internal names correctly.
484494
uri = ("mongodb://example.com/?tls=true&appname=myapp&maxPoolSize=10&"

0 commit comments

Comments
 (0)