rdobuilder bad9dd
From 08e863f94fe93b4b3bd2e8267234be7a23350b1d Mon Sep 17 00:00:00 2001
rdobuilder bad9dd
From: Adam Williamson <awilliam@redhat.com>
rdobuilder bad9dd
Date: Thu, 1 Aug 2024 12:58:38 -0700
rdobuilder bad9dd
Subject: [PATCH] Don't create default SSLContext if CA bundle isn't present
rdobuilder bad9dd
rdobuilder bad9dd
Similar to e18879932287c2bf4bcee4ddf6ccb8a69b6fc656 , this also
rdobuilder bad9dd
skips creation of the default SSLContext on FileNotFoundError,
rdobuilder bad9dd
which is raised if DEFAULT_CA_BUNDLE_PATH does not exist.
rdobuilder bad9dd
rdobuilder bad9dd
See: https://bugzilla.redhat.com/show_bug.cgi?id=2297632
rdobuilder bad9dd
rdobuilder bad9dd
Signed-off-by: Adam Williamson <awilliam@redhat.com>
rdobuilder bad9dd
---
rdobuilder bad9dd
 src/requests/adapters.py | 5 +++--
rdobuilder bad9dd
 1 file changed, 3 insertions(+), 2 deletions(-)
rdobuilder bad9dd
rdobuilder bad9dd
diff --git a/src/requests/adapters.py b/src/requests/adapters.py
rdobuilder bad9dd
index 9a58b160..fb151a95 100644
rdobuilder bad9dd
--- a/src/requests/adapters.py
rdobuilder bad9dd
+++ b/src/requests/adapters.py
rdobuilder bad9dd
@@ -81,9 +81,10 @@ try:
rdobuilder bad9dd
     _preloaded_ssl_context.load_verify_locations(
rdobuilder bad9dd
         extract_zipped_paths(DEFAULT_CA_BUNDLE_PATH)
rdobuilder bad9dd
     )
rdobuilder bad9dd
-except ImportError:
rdobuilder bad9dd
+except (ImportError, FileNotFoundError):
rdobuilder bad9dd
     # Bypass default SSLContext creation when Python
rdobuilder bad9dd
-    # interpreter isn't built with the ssl module.
rdobuilder bad9dd
+    # interpreter isn't built with the ssl module, or
rdobuilder bad9dd
+    # DEFAULT_CA_BUNDLE_PATH isn't present
rdobuilder bad9dd
     _preloaded_ssl_context = None
rdobuilder bad9dd
 
rdobuilder bad9dd
 
rdobuilder bad9dd
-- 
rdobuilder bad9dd
2.45.2
rdobuilder bad9dd