Skip to content
Myr

Try to use the OS's CA certificate bundle for SSL verification

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Shivaram Lingamneni · committed by Shivaram Lingamneni · parent 2f6b5fe · Browse files · 3 files+23 added−3 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+23 added−3 removed

  • other:+23 added−3 removed

3 files+23 added−3 removed

modified:requests/models.py+7 added-3 removed
25 unmodified lines
26 ConnectionError, HTTPError, RequestException, Timeout, TooManyRedirects,27 URLRequired, SSLError, MissingSchema, InvalidSchema, InvalidURL)28from .utils import (29 get_encoding_from_headers, stream_untransfer, guess_filename, requote_uri,30 dict_from_string, stream_decode_response_unicode, get_netrc_auth)30 dict_from_string, stream_decode_response_unicode, get_netrc_auth, CA_BUNDLE_PATH)31from .compat import (32 urlparse, urlunparse, urljoin, urlsplit, urlencode, str, bytes,33 SimpleCookie, is_py2)34
488 unmodified lines
523 else:524 conn = connectionpool.connection_from_url(url)525 except LocationParseError as e:526 raise InvalidURL(e)527 527528 if url.startswith('https') and self.verify:529530 cert_loc = None531
4 unmodified lines
536 # Look for configuration.537 if not cert_loc and self.config.get('trust_env'):538 cert_loc = os.environ.get('REQUESTS_CA_BUNDLE')539540 # Curl compatiblity.540 # Curl compatibility.541 if not cert_loc and self.config.get('trust_env'):542 cert_loc = os.environ.get('CURL_CA_BUNDLE')543544 # Use the operating system's bundle, if it can be found.545 if not cert_loc:546 cert_loc = CA_BUNDLE_PATH547548 # Use the awesome certifi list.549 if not cert_loc:550 cert_loc = __import__('certifi').where()551
294 unmodified lines
modified:requests/utils.py+15 added
22 unmodified lines
232425NETRC_FILES = ('.netrc', '_netrc')2627# common paths for the OS's CA certificate bundle28POSSIBLE_CA_BUNDLE_PATHS = [29 # Red Hat, CentOS, Fedora and friends:30 '/etc/pki/tls/certs/ca-bundle.crt',31 # Ubuntu and friends:32 '/etc/ssl/certs/ca-certificates.crt',33]3435def get_ca_bundle_path():36 """Try to pick an available CA certificate bundle provided by the OS."""37 for path in POSSIBLE_CA_BUNDLE_PATHS:38 if os.path.exists(path):39 return path4041CA_BUNDLE_PATH = get_ca_bundle_path()4243def dict_to_sequence(d):44 """Returns an internal sequence dictionary update."""4546 if hasattr(d, 'items'):
443 unmodified lines
modified:AUTHORS.rst+1 added
93 unmodified lines
94- Steve Pulec95- Michael Kelly96- Michael Newman <newmaniese@gmail.com>97- Jonty Wareing <jonty@jonty.co.uk>98- Shivaram Lingamneni