File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change 77# SSL module with m2crypto backend for HSM support.
88
99import ssl
10+ import sys
11+ import logging
1012
1113pkcs11 = None
1214
@@ -29,7 +31,7 @@ def wrap_socket(sock, ssl_params={}):
2931 ctx = ssl .SSLContext (ssl .PROTOCOL_TLS_CLIENT )
3032 if hasattr (ctx , "set_default_verify_paths" ):
3133 ctx .set_default_verify_paths ()
32- if verify != ssl .CERT_REQUIRED :
34+ if hasattr ( ctx , "check_hostname" ) and verify != ssl .CERT_REQUIRED :
3335 ctx .check_hostname = False
3436 ctx .verify_mode = verify
3537 if keyfile is not None and certfile is not None :
@@ -41,7 +43,11 @@ def wrap_socket(sock, ssl_params={}):
4143 return ctx .wrap_socket (sock , server_hostname = hostname )
4244 else :
4345 # Use M2Crypto to load key and cert from HSM.
44- from M2Crypto import m2 , SSL , Engine
46+ try :
47+ from M2Crypto import m2 , SSL , Engine
48+ except (ImportError , AttributeError ):
49+ logging .error ("The m2crypto module is required to use HSM." )
50+ sys .exit (1 )
4551
4652 global pkcs11
4753 if pkcs11 is None :
You can’t perform that action at this time.
0 commit comments