From d0d053562ba372631695f17564cd2eba41ef90a5 Mon Sep 17 00:00:00 2001 From: Robert Bikar Date: Sun, 29 Oct 2023 18:22:33 +0100 Subject: [PATCH] Fix setting verify for requests Due to bug https://github.com/psf/requests/issues/3829, setting 'verify' on session doesn't work if REQUESTS_CA_BUNDLE is set on environment. The bundle defined via REQUESTS_CA_BUNDLE will take precedence and the custom bundle provided via 'verify' is ignored. Let's now set 'verify' for each request. This can be revetrted when the bug is fixed, likely in python-requests-v3. --- ubipop/_cdn.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ubipop/_cdn.py b/ubipop/_cdn.py index 0bfb202..c58efe8 100644 --- a/ubipop/_cdn.py +++ b/ubipop/_cdn.py @@ -216,6 +216,10 @@ def _session(self): return self._tls.session def _head(self, *args, **kwargs): + # set verify for each request + # verify set on session doesn't work due to https://github.com/psf/requests/issues/3829 + # if REQUESTS_CA_BUNDLE is set on env, it takes precedence + kwargs["verify"] = self._session.verify return self._session.head(*args, **kwargs) def _on_failure(self, header, exception):