psf / requests

A simple, yet elegant, HTTP library.
https://requests.readthedocs.io/en/latest/
Apache License 2.0
52.16k stars 9.33k forks source link

SSL Get Server Certificate Error #2995

Closed ghost closed 8 years ago

ghost commented 8 years ago

I'm getting certificate verify failed errors for a few websites including Google. I've just tried with a new Digital Ocean droplet and still having the same issues so it's not just my server.

I did the following, create a new Ubuntu 14.04 droplet on Digital Ocean. Installed python-pip (python and OpenSSL were already installed). Upgraded requests to the latest version (pip install requests --upgrade) and installed security (pip install requests[security]). Just to confirm, the droplet originally came with requests version 2.2.1, hence the reason for upgrading to 2.9.1. I also installed the pip modules: certifi and urllib3.

Before upgrading requests and installing the other modules, I ran import requests and requests.get("https://www.google.co.uk"). This worked fine and returned 200.

After upgrading and installing the other packages, I got the following: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/lib/python2.7/dist-packages/requests/api.py", line 67, in get return request('get', url, params=params, **kwargs) File "/usr/local/lib/python2.7/dist-packages/requests/api.py", line 53, in request return session.request(method=method, url=url, **kwargs) File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 468, in request resp = self.send(prep, **send_kwargs) File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 576, in send r = adapter.send(request, **kwargs) File "/usr/local/lib/python2.7/dist-packages/requests/adapters.py", line 447, in send raise SSLError(e, request=request) requests.exceptions.SSLError: [Errno 1] _ssl.c:510: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed

I tried it on https://github.com and it worked perfectly. I tried it on https://google.com and https://themoviedb.org and both has certificate verify failed errors even though they both have valid certificates.

Lukasa commented 8 years ago

You'll need to read certifi/python-certifi#26.