python-requests/requests-use_directory_cert_store.patch

46 lines
1.7 KiB
Diff

Index: requests-0.12.1/requests/utils.py
===================================================================
--- requests-0.12.1.orig/requests/utils.py
+++ requests-0.12.1/requests/utils.py
@@ -14,6 +14,9 @@ import codecs
import os
import random
import re
+import socket
+import ssl
+import _ssl
import zlib
from netrc import netrc, NetrcParseError
@@ -51,9 +54,14 @@ def get_os_ca_bundle_path():
return path
return None
-# if certifi is installed, use its CA bundle;
-# otherwise, try and use the OS bundle
-DEFAULT_CA_BUNDLE_PATH = CERTIFI_BUNDLE_PATH or get_os_ca_bundle_path()
+# If SSL module can load a directory-based store, use that
+try:
+ _ssl.sslwrap(socket.socket()._sock, False, None, None, ssl.CERT_REQUIRED, ssl.PROTOCOL_SSLv23, "/etc/ssl/certs", None)
+ DEFAULT_CA_BUNDLE_PATH = "/etc/ssl/certs"
+except ssl.SSLError:
+ # if certifi is installed, use its CA bundle;
+ # otherwise, try and use the OS bundle
+ DEFAULT_CA_BUNDLE_PATH = CERTIFI_BUNDLE_PATH or get_os_ca_bundle_path()
def dict_to_sequence(d):
"""Returns an internal sequence dictionary update."""
Index: requests-0.12.1/setup.py
===================================================================
--- requests-0.12.1.orig/setup.py
+++ requests-0.12.1/setup.py
@@ -34,7 +34,7 @@ packages = [
# On certain supported platforms (e.g., Red Hat / Debian / FreeBSD), Requests can
# use the system CA bundle instead; see `requests.utils` for details.
# If your platform is supported, set `requires` to [] instead:
-requires = ['certifi>=0.0.7']
+requires = []
# chardet is used to optimally guess the encodings of pages that don't declare one.
# At this time, chardet is not a required dependency. However, it's sufficiently