6

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?

halfer
  • 19,824
  • 17
  • 99
  • 186
code-8
  • 54,650
  • 106
  • 352
  • 604

2 Answers2

3

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
2ps
  • 15,099
  • 2
  • 27
  • 47
  • You may need that `--force-link`, too. I don't use Brew, so I'm not sure if that's what its called. But it shows up often for Mac, Brew and OpenSSL questions. – jww Nov 08 '16 at 18:27
  • 2
    Even my python now is 2.7.12 - I got this `curl: (35) error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure` when I run this `curl https://randomuser.me/api/` – code-8 Nov 08 '16 at 18:53
  • Do you have any other suggestions ? – code-8 Nov 08 '16 at 20:29
  • @ihue: what is the output of `curl --version`? – 2ps Nov 09 '16 at 02:26
0

I would make sure they are running on port 443 for https and you are not getting a redirect if on Linux you can use dig +short example.com I ran into the same issue on google hosted sites, with that command if it is google hosted you should get an output similar to ghs.googlehosted.com or the redirected url in this case I believe google hosted sites will redirect due to a Web application Firewall. When I attempt to visit the url that I get the error on from the requests.get(domain) I get redirected to login portal