File tree Expand file tree Collapse file tree 1 file changed +14
-7
lines changed Expand file tree Collapse file tree 1 file changed +14
-7
lines changed Original file line number Diff line number Diff line change 18
18
19
19
from ssl import CERT_REQUIRED
20
20
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
22
23
23
24
# Enable logs in this format:
24
25
# 2020-06-08 23:49:35,982 DEBUG ocsp_support Peer did not staple an OCSP response
25
26
FORMAT = '%(asctime)s %(levelname)s %(module)s %(message)s'
26
27
logging .basicConfig (format = FORMAT , level = logging .DEBUG )
27
28
28
29
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 )
35
42
36
43
s = socket .socket ()
37
44
s .connect ((host , port ))
You can’t perform that action at this time.
0 commit comments