kennethreitz/requests — Issue #321: `requests.get('https://httpbin.org', verify=True)` fails
Author: zed
Created: 2011-12-28 13:09:34+00:00
State: open

Example from the docs doesn't work http://docs.python-requests.org/en/latest/user/advanced/#ssl-cert-verification

>>> import requests
>>> requests.get('https://httpbin.org', verify=True)
Traceback (most recent call last):
File "", line 1, in
File "/path/to/lib/python2.7/site-packages/requests/api.py", line
50, in get
return request('get', url, **kwargs)
File "/path/to/lib/python2.7/site-packages/requests/api.py", line
38, in request
return s.request(method=method, url=url, **kwargs)
File "/path/to/lib/python2.7/site-packages/requests/sessions.py",
line 200, in request
r.send(prefetch=prefetch)
File "/path/to/lib/python2.7/site-packages/requests/models.py", li
ne 502, in send
raise SSLError(e)
SSLError: [Errno 1] _ssl.c:503: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certi
ficate verify failed
>>> requests.__version__
'0.9.0'
>>> import ssl
>>> ssl.OPENSSL_VERSION
'OpenSSL 1.0.0e 6 Sep 2011'

$ pip freeze | grep certifi
certifi==0.0.6
$ python -mplatform
Linux-3.0.0-14-generic-i686-with-Ubuntu-11.10-oneiric

I've also tried to specify path to httpbin certificate:

>>> requests.get('https://httpbin.org', verify='./httpbin.pem')
Traceback (most recent call last):
File "", line 1, in
File "/path/to/lib/python2.7/site-packages/requests/api.py", line
50, in get
return request('get', url, **kwargs)
File "/path/to/lib/python2.7/site-packages/requests/api.py", line
38, in request
return s.request(method=method, url=url, **kwargs)
File "/path/to/lib/python2.7/site-packages/requests/sessions.py",
line 200, in request
r.send(prefetch=prefetch)
File "/path/to/lib/python2.7/site-packages/requests/models.py", li
ne 502, in send
raise SSLError(e)
SSLError: [Errno 1] _ssl.c:503: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certi
ficate verify failed
>>> print open('./httpbin.pem').read(),
-----BEGIN CERTIFICATE-----
MIIEPjCCAyagAwIBAgIDBEmFMA0GCSqGSIb3DQEBBQUAMDwxCzAJBgNVBAYTAlVT
MRcwFQYDVQQKE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SG3vSSxBVdF/vZ1rAURU6ztOFaYiPC6jg
GWdNNOwljG4tkf5bCGh6XJjlMtLosz7QtcKprTvoMuCYSTKR5VTxJqgWbdhds4oU
nBnI0YzcgZR9qtVItCaZfl5487gYuIertX8le0cJBAG+X8I14AKAsBGJ/+HFbtRV
aWa4M7Faw6jTLxrc/NjiCFSs4RB38vpLkcbUa0jOTN4czPmSgWJHiaEnleUQ+AO9
L+0f+4Y1HULBFJAOJ1VjIdY0JEt67CFulkdbMXZ8qrGldpWYLlHqsoUH1xYS9g0F
RufOesXsqmteRxjKo8KocDpxw+RSFvyJL4sRBzBobHLWyg==
-----END CERTIFICATE-----

Firefox for `https://httpbin.org` says:

httpbin.org uses an invalid security certificate.

The certificate is not trusted because no issuer chain was provided.