Make 3.5 client compatible with python 3.6

This commit is contained in:
Adolfo Gómez García 2021-09-29 13:42:26 +02:00
parent 41aa22fadd
commit dcb7b3e28e

View File

@ -185,8 +185,8 @@ class RestApi:
) -> typing.Any: ) -> typing.Any:
print('Open') print('Open')
ctx = ssl.create_default_context() ctx = ssl.create_default_context()
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE ctx.verify_mode = ssl.CERT_NONE
ctx.check_hostname = False
ctx.load_verify_locations(tools.getCaCertsFile()) ctx.load_verify_locations(tools.getCaCertsFile())
hostname = urllib.parse.urlparse(url)[1] hostname = urllib.parse.urlparse(url)[1]
serial = '' serial = ''
@ -212,8 +212,8 @@ class RestApi:
serial = hex(cert.serial_number)[2:] serial = hex(cert.serial_number)[2:]
response = None response = None
ctx.check_hostname = True
ctx.verify_mode = ssl.CERT_REQUIRED ctx.verify_mode = ssl.CERT_REQUIRED
ctx.check_hostname = True
def urlopen(url: str): def urlopen(url: str):
# Generate the request with the headers # Generate the request with the headers
@ -232,8 +232,8 @@ class RestApi:
# Ask about invalid certificate # Ask about invalid certificate
if certErrorCallback: if certErrorCallback:
if certErrorCallback(hostname, serial): if certErrorCallback(hostname, serial):
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE ctx.verify_mode = ssl.CERT_NONE
ctx.check_hostname = False
response = urlopen(url) response = urlopen(url)
else: else:
raise raise