Blob Blame History Raw
From 08e863f94fe93b4b3bd2e8267234be7a23350b1d Mon Sep 17 00:00:00 2001
From: Adam Williamson <awilliam@redhat.com>
Date: Thu, 1 Aug 2024 12:58:38 -0700
Subject: [PATCH] Don't create default SSLContext if CA bundle isn't present

Similar to e18879932287c2bf4bcee4ddf6ccb8a69b6fc656 , this also
skips creation of the default SSLContext on FileNotFoundError,
which is raised if DEFAULT_CA_BUNDLE_PATH does not exist.

See: https://bugzilla.redhat.com/show_bug.cgi?id=2297632

Signed-off-by: Adam Williamson <awilliam@redhat.com>
---
 src/requests/adapters.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/requests/adapters.py b/src/requests/adapters.py
index 9a58b160..fb151a95 100644
--- a/src/requests/adapters.py
+++ b/src/requests/adapters.py
@@ -81,9 +81,10 @@ try:
     _preloaded_ssl_context.load_verify_locations(
         extract_zipped_paths(DEFAULT_CA_BUNDLE_PATH)
     )
-except ImportError:
+except (ImportError, FileNotFoundError):
     # Bypass default SSLContext creation when Python
-    # interpreter isn't built with the ssl module.
+    # interpreter isn't built with the ssl module, or
+    # DEFAULT_CA_BUNDLE_PATH isn't present
     _preloaded_ssl_context = None
 
 
-- 
2.45.2