I am attempting to use rauth to do oauth with twitter, but it seems to be failing with the following error:
requests.exceptions.SSLError: [Errno 1] _ssl.c:504: error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol
After some testing, I find that requests seems to be breaking when attempting to access api.twitter.com and verifying the https connection. Here is an example, It appears to work for https://github.com, but fails for https://api.twitter.com:
>>> import requests
>>> requests.get('https://github.com', verify=True)
<Response [200]>
>>> requests.get('https://api.twitter.com/oauth/request_token',verify=True)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "requests/api.py", line 65, in get
return request('get', url, **kwargs)
File "requests/safe_mode.py", line 39, in wrapped
return function(method, url, **kwargs)
File "requests/api.py", line 51, in request
return session.request(method=method, url=url, **kwargs)
File "requests/sessions.py", line 252, in request
r.send(prefetch=prefetch)
File "requests/models.py", line 632, in send
raise SSLError(e)
requests.exceptions.SSLError: [Errno 1] _ssl.c:504: error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol
>>> requests.get('https://api.twitter.com',verify=True)
[SNIP] Same error as above
Is this a bug in requests? This should be similar to what rauth is running, so I am not sure why it is not working on my machine.
With some great disccusion from @thomas-orozco it appears to be an openssl being unable to verify the G2 VeriSign certificate: http://pastebin.com/ZZj3s5uN
It does appear that I have the VeriSign CA by using certool:
certtool y k=/System/Library/Keychains/SystemCACertificates.keychain | grep -i verisign
Which is being used by chrome / safari, just not by openssl on the command line. Is there something that I can do so that Requests will load the right certificate?