Skip to content

Commit 70fb1cc

Browse files
committed
PYTHON-2293 Fix OCSP test script for Windows
1 parent 69dde9e commit 70fb1cc

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

tools/ocsptest.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,27 @@
1818

1919
from ssl import CERT_REQUIRED
2020

21-
from pymongo.pyopenssl_context import SSLContext, PROTOCOL_SSLv23
21+
from pymongo.pyopenssl_context import SSLContext
22+
from pymongo.ssl_support import get_ssl_context
2223

2324
# Enable logs in this format:
2425
# 2020-06-08 23:49:35,982 DEBUG ocsp_support Peer did not staple an OCSP response
2526
FORMAT = '%(asctime)s %(levelname)s %(module)s %(message)s'
2627
logging.basicConfig(format=FORMAT, level=logging.DEBUG)
2728

2829
def check_ocsp(host, port, capath):
29-
ctx = SSLContext(PROTOCOL_SSLv23)
30-
ctx.verify_mode = CERT_REQUIRED
31-
if capath is not None:
32-
ctx.load_verify_locations(capath)
33-
else:
34-
ctx.set_default_verify_paths()
30+
ctx = get_ssl_context(
31+
None, # certfile
32+
None, # keyfile
33+
None, # passphrase
34+
capath,
35+
CERT_REQUIRED,
36+
None, # crlfile
37+
True, # match_hostname
38+
True) # check_ocsp_endpoint
39+
40+
# Ensure we're using pyOpenSSL.
41+
assert isinstance(ctx, SSLContext)
3542

3643
s = socket.socket()
3744
s.connect((host, port))

0 commit comments

Comments
 (0)