From 3c76691c9054af853e2dc753f232aab4de1dc333 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ant=C3=B4nio=20Vieira?= Date: Mon, 6 May 2024 14:04:49 -0300 Subject: [PATCH 1/2] fix: enviroment variable PYTHONHTTPSVERIFY is not take in consideration on https requests. In case of the ssl certificate of destination host has expired isn't possible to ignore the cert validation using env PYTHONHTTPSVERIFY=1. --- src/requests/adapters.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/requests/adapters.py b/src/requests/adapters.py index 84ec48fc70..208fa14ef7 100644 --- a/src/requests/adapters.py +++ b/src/requests/adapters.py @@ -522,7 +522,14 @@ def send( conn = self._get_connection(request, verify, proxies=proxies, cert=cert) except LocationValueError as e: raise InvalidURL(e, request=request) - + + python_https_verify = '1' + if 'PYTHONHTTPSVERIFY' in os.environ: + python_https_verify = os.environ['PYTHONHTTPSVERIFY'] + if ((python_https_verify is None) or (python_https_verify == '') or (python_https_verify != '0') or (python_https_verify != '1')): + python_https_verify = '0' + verify = True if python_https_verify == '1' else False + self.cert_verify(conn, request.url, verify, cert) url = self.request_url(request, proxies) self.add_headers( From 6cace1b989479b1c62736e18b3ca0a6b83f0d596 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ant=C3=B4nio=20Vieira?= Date: Mon, 6 May 2024 14:32:20 -0300 Subject: [PATCH 2/2] fix: enviroment variable PYTHONHTTPSVERIFY isn't take in consideration on https requests. In case of the ssl certificate of destination host has expired isn't possible to ignore the cert validation using env PYTHONHTTPSVERIFY=1. putting "import os". --- src/requests/adapters.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/requests/adapters.py b/src/requests/adapters.py index 208fa14ef7..83298b7c8c 100644 --- a/src/requests/adapters.py +++ b/src/requests/adapters.py @@ -6,6 +6,7 @@ and maintain connections. """ +import os import os.path import socket # noqa: F401 import typing