Skip to content

Commit fe1d19d

Browse files
committed
PYTHON-2866 Setting tlsDisableOCSPEndpointCheck=false must enable OCSP endpoint check
1 parent 22bbc1a commit fe1d19d

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
@@ -634,12 +634,14 @@ def validate_tzinfo(dummy, value):
634634
'tls': validate_boolean_or_string,
635635
'tlsallowinvalidcertificates': validate_allow_invalid_certs,
636636
'ssl_cert_reqs': validate_cert_reqs,
637+
# Normalized to ssl_match_hostname which is the logical inverse of tlsallowinvalidhostnames
637638
'tlsallowinvalidhostnames': lambda *x: not validate_boolean_or_string(*x),
638639
'ssl_match_hostname': validate_boolean_or_string,
639640
'tlscafile': validate_readable,
640641
'tlscertificatekeyfile': validate_readable,
641642
'tlscertificatekeyfilepassword': validate_string_or_none,
642-
'tlsdisableocspendpointcheck': validate_boolean_or_string,
643+
# Normalized to ssl_check_ocsp_endpoint which is the logical inverse of tlsdisableocspendpointcheck
644+
'tlsdisableocspendpointcheck': lambda *x: not validate_boolean_or_string(*x),
643645
'tlsinsecure': validate_boolean_or_string,
644646
'w': validate_non_negative_int_or_basestring,
645647
'wtimeoutms': validate_non_negative_integer,

test/test_uri_parser.py

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

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

0 commit comments

Comments
 (0)