diff --git a/requests/adapters.py b/requests/adapters.py index fd46325a..0d461b35 100644 --- a/requests/adapters.py +++ b/requests/adapters.py @@ -241,6 +241,7 @@ class HTTPAdapter(BaseAdapter): conn.key_file = cert[1] else: conn.cert_file = cert + conn.key_file = None if conn.cert_file and not os.path.exists(conn.cert_file): raise IOError("Could not find the TLS certificate file, " "invalid path: {0}".format(conn.cert_file)) diff --git a/tests/test_requests.py b/tests/test_requests.py index 0dad423c..d8a42151 100755 --- a/tests/test_requests.py +++ b/tests/test_requests.py @@ -786,6 +786,10 @@ class TestRequests: requests.get(httpbin_secure(), cert=('.', INVALID_PATH)) assert str(e.value) == 'Could not find the TLS key file, invalid path: {0}'.format(INVALID_PATH) + def test_http_with_certificate(self, httpbin): + r = requests.get(httpbin(), cert='.') + assert r.status_code == 200 + def test_https_warnings(self, httpbin_secure, httpbin_ca_bundle): """warnings are emitted with requests.get""" if HAS_MODERN_SSL or HAS_PYOPENSSL: