Changeset 120
- Timestamp:
- 03/01/17 19:03:44 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/bletchley/ssltls.py
r115 r120 55 55 56 56 57 def startSSLTLS(sock, mode='client', handshake=SSL.TLSv1_METHOD, key=None, certChain=[], cipher_list=None):57 def startSSLTLS(sock, mode='client', protocol=SSL.TLSv1_METHOD, key=None, certChain=[], cipher_list=None): 58 58 ''' 59 59 cipher_list example: b'DH-DSS-AES256-GCM-SHA384:DHE-DSS-AES256-GCM-SHA384:DH-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA256:DH-RSA-AES256-SHA256:DH-DSS-AES256-SHA256:DHE-RSA-AES256-SHA:DHE-DSS-AES256-SHA:DH-RSA-AES256-SHA:DH-DSS-AES256-SHA:DHE-RSA-CAMELLIA256-SHA:DHE-DSS-CAMELLIA256-SHA:DH-RSA-CAMELLIA256-SHA:DH-DSS-CAMELLIA256-SHA:ADH-AES256-GCM-SHA384:ADH-AES256-SHA256:ADH-AES256-SHA:ADH-CAMELLIA256-SHA:DH-DSS-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:DH-RSA-AES128-GCM-SHA256:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES128-SHA256:DHE-DSS-AES128-SHA256:DH-RSA-AES128-SHA256:DH-DSS-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA:DH-RSA-AES128-SHA:DH-DSS-AES128-SHA:DHE-RSA-SEED-SHA:DHE-DSS-SEED-SHA:DH-RSA-SEED-SHA:DH-DSS-SEED-SHA:DHE-RSA-CAMELLIA128-SHA:DHE-DSS-CAMELLIA128-SHA:DH-RSA-CAMELLIA128-SHA:DH-DSS-CAMELLIA128-SHA:ADH-AES128-GCM-SHA256:ADH-AES128-SHA256:ADH-AES128-SHA:ADH-SEED-SHA:ADH-CAMELLIA128-SHA:ADH-RC4-MD5:EDH-RSA-DES-CBC3-SHA:EDH-DSS-DES-CBC3-SHA:DH-RSA-DES-CBC3-SHA:DH-DSS-DES-CBC3-SHA:ADH-DES-CBC3-SHA' 60 60 ''' 61 61 62 context = createContext( handshake, key=key, certChain=certChain)62 context = createContext(protocol, key=key, certChain=certChain) 63 63 if cipher_list: 64 64 context.set_cipher_list(cipher_list) … … 66 66 #context.set_options(OpenSSL.SSL.OP_SINGLE_DH_USE) 67 67 #context.set_options(OpenSSL.SSL.OP_EPHEMERAL_RSA) 68 68 69 69 conn = SSL.Connection(context, sock) 70 70 if mode == 'client': … … 77 77 78 78 79 def ConnectSSLTLS(host, port ):79 def ConnectSSLTLS(host, port, cipher_list=None, handshake_callback=None): 80 80 protocols = [("SSL 2/3", SSL.SSLv23_METHOD), 81 81 ("TLS 1.0", SSL.TLSv1_METHOD), … … 91 91 92 92 try: 93 conn = startSSLTLS(serverSock, mode='client', handshake=p) 93 if handshake_callback: 94 if not handshake_callback(serverSock): 95 return None 96 except Exception as e: 97 traceback.print_exc(file=sys.stderr) 98 return None 99 100 try: 101 conn = startSSLTLS(serverSock, mode='client', protocol=p, cipher_list=cipher_list) 94 102 break 95 103 except ValueError as e: 96 sys.stderr.write("%s handshakenot supported by your openssl library, trying others...\n" % pname)104 sys.stderr.write("%s protocol not supported by your openssl library, trying others...\n" % pname) 97 105 except SSL.Error as e: 98 106 sys.stderr.write("Exception during %s handshake with server." % pname)
Note: See TracChangeset
for help on using the changeset viewer.