Python Requests Not Respecting verify=False

Viewed 1272

Python requests is giving me an ssl handshake failure even when verify=False (I know that not using SSL is inadvisable). Requests works as expected for me with other sites that have valid certs. I'm using 2.7.

from lxml import html
import requests
import csv

outputfile  = open('/Users/jim/Documents/FabFoundationURLs.csv', "wb")
writer = csv.writer(outputfile, delimiter=';', quotechar='"', quoting=csv.QUOTE_MINIMAL)

source = 'https://www.fablabs.io/labs'

page = requests.get(source, verify=False)
tree = html.fromstring(page.content)

#This will create a list of links:
links = tree.xpath('/html/body/div[@id="main"]/div[2]/div[1]/div[2]//span/a/text()')

targets = links

print links

Here's the exception:

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

SSL handshake error can be a protocol error instead of a cert verification error. In this case it happens before the cert verification: you can't establish the SSL connection and verify=False won't help. Protocol error generally refers to an unknown/unistalled SSL cipher version.

You can try to reinstall extra ciphers in requests (worked for me on Ubuntu 18.04, but not on OS X)

pip install requests[security]
Related