Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

requests.exceptions.SSLError

I have fiddle.py containing 4 lines

import requests

url = "https://randomuser.me/api/"
locations = requests.get(url,verify=False).json()

print locations

When I run it, I kept getting

requests.exceptions.SSLError: [SSL: SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3 alert handshake failure (_ssl.c:590)


Try #1

Set verify=False

Run the code, Same Error.


Try #2

Run sudo pip install --upgrade requests

Run the code, same error.


Try #3

Run

sudo pip install --upgrade pip

and

sudo pip install requests[security]

Run the code, different error.

requests.exceptions.SSLError: ("bad handshake: Error([('SSL routines', 'SSL23_GET_SERVER_HELLO', 'sslv3 alert handshake failure')],)",)


Details

  • Python 2.7.10
  • OpenSSL 0.9.8zh 14 Jan 2016
  • Mac OS X 10.11.6

How can I debug this?

like image 484
code-8 Avatar asked Nov 08 '16 16:11

code-8


People also ask

How do I stop SSL certificate warning message in Python?

This can be avoided by using urlib3. disable_warnings method. The above warning that occurred while using verify=False in the request method can be suppressed by using the urllib3. disable_warnings method.


1 Answers

You want to be on OpenSSL 1.0.2 and python 2.7.12. You will probably also want the latest curl.

brew update
brew upgrade openssl
brew upgrade curl
brew upgrade python

python --version # make sure you have python 2.7.12
curl https://randomuser.me/api/ # to verify
like image 124
2ps Avatar answered Oct 28 '22 17:10

2ps