tools.web: restore Python3.3 behavior: don't check server certificate
This commit is contained in:
parent
8988dd0d41
commit
9b2bc27374
1 changed files with 16 additions and 5 deletions
|
@ -75,14 +75,25 @@ def getURLContent(url, body=None, timeout=7):
|
||||||
|
|
||||||
import http.client
|
import http.client
|
||||||
|
|
||||||
|
kwargs = {
|
||||||
|
'host': o.hostname,
|
||||||
|
'port': o.port,
|
||||||
|
'timeout': timeout
|
||||||
|
}
|
||||||
|
|
||||||
if o.scheme == "http":
|
if o.scheme == "http":
|
||||||
conn = http.client.HTTPConnection(o.hostname, port=o.port,
|
conn = http.client.HTTPConnection(**kwargs)
|
||||||
timeout=timeout)
|
|
||||||
elif o.scheme == "https":
|
elif o.scheme == "https":
|
||||||
conn = http.client.HTTPSConnection(o.hostname, port=o.port,
|
# For Python>3.4, restore the Python 3.3 behavior
|
||||||
timeout=timeout)
|
import ssl
|
||||||
|
if hasattr(ssl, "create_default_context"):
|
||||||
|
kwargs["context"] = ssl.create_default_context()
|
||||||
|
kwargs["context"].check_hostname = False
|
||||||
|
kwargs["context"].verify_mode = ssl.CERT_NONE
|
||||||
|
|
||||||
|
conn = http.client.HTTPSConnection(**kwargs)
|
||||||
elif o.scheme is None or o.scheme == "":
|
elif o.scheme is None or o.scheme == "":
|
||||||
conn = http.client.HTTPConnection(o.hostname, port=80, timeout=timeout)
|
conn = http.client.HTTPConnection(**kwargs)
|
||||||
else:
|
else:
|
||||||
raise IRCException("Invalid URL")
|
raise IRCException("Invalid URL")
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue