mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2024-11-25 19:13:48 +03:00
Patch related to #1256
This commit is contained in:
parent
a18c69d78b
commit
c7ec1534a6
|
@ -43,11 +43,14 @@ class HTTPSConnection(httplib.HTTPSConnection):
|
||||||
|
|
||||||
success = False
|
success = False
|
||||||
|
|
||||||
if not kb.tlsSNI:
|
# Reference(s): https://docs.python.org/2/library/ssl.html#ssl.SSLContext
|
||||||
for protocol in _protocols:
|
# https://www.mnot.net/blog/2014/12/27/python_2_and_tls_sni
|
||||||
|
if kb.tlsSNI != False and hasattr(ssl, "SSLContext"):
|
||||||
|
for protocol in filter(lambda _: _ >= ssl.PROTOCOL_TLSv1, _protocols):
|
||||||
try:
|
try:
|
||||||
sock = create_sock()
|
sock = create_sock()
|
||||||
_ = ssl.wrap_socket(sock, self.key_file, self.cert_file, ssl_version=protocol)
|
context = ssl.SSLContext(protocol)
|
||||||
|
_ = context.wrap_socket(sock, do_handshake_on_connect=False, server_hostname=self.host)
|
||||||
if _:
|
if _:
|
||||||
success = True
|
success = True
|
||||||
self.sock = _
|
self.sock = _
|
||||||
|
@ -60,16 +63,16 @@ class HTTPSConnection(httplib.HTTPSConnection):
|
||||||
self._tunnel_host = None
|
self._tunnel_host = None
|
||||||
logger.debug("SSL connection error occurred ('%s')" % getSafeExString(ex))
|
logger.debug("SSL connection error occurred ('%s')" % getSafeExString(ex))
|
||||||
|
|
||||||
# Reference(s): https://docs.python.org/2/library/ssl.html#ssl.SSLContext
|
if kb.tlsSNI is None:
|
||||||
# https://www.mnot.net/blog/2014/12/27/python_2_and_tls_sni
|
kb.tlsSNI = success
|
||||||
if not success and hasattr(ssl, "SSLContext"):
|
|
||||||
for protocol in filter(lambda _: _ >= ssl.PROTOCOL_TLSv1, _protocols):
|
if not success:
|
||||||
|
for protocol in _protocols:
|
||||||
try:
|
try:
|
||||||
sock = create_sock()
|
sock = create_sock()
|
||||||
context = ssl.SSLContext(protocol)
|
_ = ssl.wrap_socket(sock, self.key_file, self.cert_file, ssl_version=protocol)
|
||||||
_ = context.wrap_socket(sock, do_handshake_on_connect=False, server_hostname=self.host)
|
|
||||||
if _:
|
if _:
|
||||||
kb.tlsSNI = success = True
|
success = True
|
||||||
self.sock = _
|
self.sock = _
|
||||||
_protocols.remove(protocol)
|
_protocols.remove(protocol)
|
||||||
_protocols.insert(0, protocol)
|
_protocols.insert(0, protocol)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user