1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-11-10 22:56:15 +01:00

Fix ValueError: Cannot set verify_mode to CERT_NONE when check_hostname is enabled

This commit is contained in:
Daniel Mach 2023-05-24 14:29:39 +02:00
parent 56de8ceebb
commit 14fba8bcb7

View File

@ -252,9 +252,19 @@ def http_request(method: str, url: str, headers=None, data=None, file=None, retr
if purl.scheme == "https":
ssl_context = oscssl.create_ssl_context()
ssl_context.load_default_certs()
# turn cert verification off if sslcertck = 0
pool_kwargs["cert_reqs"] = "CERT_REQUIRED" if options["sslcertck"] else "CERT_NONE"
pool_kwargs["ssl_context"] = ssl_context
# turn cert verification off if sslcertck = 0
# urllib3 v1
pool_kwargs["cert_reqs"] = "CERT_REQUIRED" if options["sslcertck"] else "CERT_NONE"
# urllib3 v2
if options["sslcertck"]:
ssl_context.check_hostname = True
ssl_context.verify_mode = ssl.CERT_REQUIRED
else:
ssl_context.check_hostname = False
ssl_context.verify_mode = ssl.CERT_NONE
if purl.scheme == "http" and HTTP_PROXY_MANAGER and not urllib.request.proxy_bypass(url):
# connection through HTTP proxy