| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent a18c69d commit c7ec153
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -43,11 +43,14 @@ def create_sock(): | |||
| 43 | 43 | ||
| 44 | 44 | success = False | |
| 45 | 45 | ||
| 46 | - if not kb.tlsSNI: | ||
| 47 | - for protocol in _protocols: | ||
| 46 | + # Reference(s): https://docs.python.org/2/library/ssl.html#ssl.SSLContext | ||
| 47 | + # https://www.mnot.net/blog/2014/12/27/python_2_and_tls_sni | ||
| 48 | + if kb.tlsSNI != False and hasattr(ssl, "SSLContext"): | ||
| 49 | + for protocol in filter(lambda _: _ >= ssl.PROTOCOL_TLSv1, _protocols): | ||
| 48 | 50 | try: | |
| 49 | 51 | sock = create_sock() | |
| 50 | - _ = ssl.wrap_socket(sock, self.key_file, self.cert_file, ssl_version=protocol) | ||
| 52 | + context = ssl.SSLContext(protocol) | ||
| 53 | + _ = context.wrap_socket(sock, do_handshake_on_connect=False, server_hostname=self.host) | ||
| 51 | 54 | if _: | |
| 52 | 55 | success = True | |
| 53 | 56 | self.sock = _ | |
@@ -60,16 +63,16 @@ def create_sock(): | |||
| 60 | 63 | self._tunnel_host = None | |
| 61 | 64 | logger.debug("SSL connection error occurred ('%s')" % getSafeExString(ex)) | |
| 62 | 65 | ||
| 63 | - # Reference(s): https://docs.python.org/2/library/ssl.html#ssl.SSLContext | ||
| 64 | - # https://www.mnot.net/blog/2014/12/27/python_2_and_tls_sni | ||
| 65 | - if not success and hasattr(ssl, "SSLContext"): | ||
| 66 | - for protocol in filter(lambda _: _ >= ssl.PROTOCOL_TLSv1, _protocols): | ||
| 66 | + if kb.tlsSNI is None: | ||
| 67 | + kb.tlsSNI = success | ||
| 68 | + | ||
| 69 | + if not success: | ||
| 70 | + for protocol in _protocols: | ||
| 67 | 71 | try: | |
| 68 | 72 | sock = create_sock() | |
| 69 | - context = ssl.SSLContext(protocol) | ||
| 70 | - _ = context.wrap_socket(sock, do_handshake_on_connect=False, server_hostname=self.host) | ||
| 73 | + _ = ssl.wrap_socket(sock, self.key_file, self.cert_file, ssl_version=protocol) | ||
| 71 | 74 | if _: | |
| 72 | - kb.tlsSNI = success = True | ||
| 75 | + success = True | ||
| 73 | 76 | self.sock = _ | |
| 74 | 77 | _protocols.remove(protocol) | |
| 75 | 78 | _protocols.insert(0, protocol) | |
| Back | FazBrowse Home | New Git URL |
0 commit comments