Skip to content

Commit 478e2a3

Browse files
committed
Don't override httplib2 certificates at module level.
This creates problems when other parts of a runtime are using httplib2 with custom bundles.
1 parent 95af393 commit 478e2a3

2 files changed

Lines changed: 8 additions & 6 deletions

File tree

github2/request.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,19 @@
4545
for cert_file in ['/etc/ssl/certs/ca-certificates.crt',
4646
'/etc/pki/tls/certs/ca-bundle.crt']:
4747
if path.exists(cert_file):
48-
httplib2.CA_CERTS = cert_file
48+
CA_CERTS = cert_file
4949
SYSTEM_CERTS = True
5050
break
5151
elif not SYSTEM_CERTS and sys.platform.startswith('freebsd'):
5252
if path.exists('/usr/local/share/certs/ca-root-nss.crt'):
53-
httplib2.CA_CERTS = '/usr/local/share/certs/ca-root-nss.crt'
53+
CA_CERTS = '/usr/local/share/certs/ca-root-nss.crt'
5454
SYSTEM_CERTS = True
5555
if SYSTEM_CERTS:
5656
LOGGER.info('Using system certificates in %r', httplib2.CA_CERTS)
5757
else:
5858
LOGGER.warning('Using bundled certificates for HTTPS connections')
59+
CA_CERTS = path.join(path.dirname(path.abspath(__file__)),
60+
"DigiCert_High_Assurance_EV_Root_CA.crt")
5961

6062

6163
def charset_from_headers(headers):
@@ -134,9 +136,8 @@ def __init__(self, username=None, api_token=None, url_prefix=None,
134136
proxy_info = httplib2.ProxyInfo(httplib2.socks.PROXY_TYPE_HTTP,
135137
proxy_host, proxy_port)
136138
self._http = httplib2.Http(proxy_info=proxy_info, cache=cache)
137-
if not SYSTEM_CERTS:
138-
self._http.ca_certs = path.join(path.dirname(path.abspath(__file__)),
139-
"DigiCert_High_Assurance_EV_Root_CA.crt")
139+
self._http.ca_certs = CA_CERTS
140+
140141

141142
def encode_authentication_data(self, extra_post_data):
142143
post_data = []

tests/utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ class HttpMock(object):
2525
Implementation tests should never span network boundaries
2626
"""
2727

28-
def __init__(self, cache=None, timeout=None, proxy_info=None):
28+
def __init__(self, cache=None, timeout=None, proxy_info=None,
29+
ca_certs=None):
2930
"""Create a mock httplib.Http object
3031
3132
.. attribute: called_with

0 commit comments

Comments
 (0)