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?
requestsissue but an SSL one. I don't seem to be experiencing the issue either. You might want to have a look at marc.info/?l=openssl-users&m=124875408916917 for some ideas on how to debug that. Basically, you should try usingopenssl s_client -debug.opensslinstall seems to be missing the following certificate:/C=US/O=VeriSign, Inc./OU=Class 3 Public Primary Certification Authority - G2/OU=(c) 1998 VeriSign, Inc. - For authorized use only/OU=VeriSign Trust Network. This is pretty surprising though, my OpenSSL install has it - but I'm running Ubuntu. Maybe gagravarr.org/writing/openssl-certs/others.shtml#ca-osx could help you.CApaths_clientparam to the dir where you certificates are located. (No idea where it is on Mac OS, though).certtool y k=/System/Library/Keychains/SystemRootCertificates.keychain | grep -i verisignit appears that I have the G(eneration)3 certs installed, and twitter is only returning the G2 cert, even though they are suppose to have gone to G3: 12weeks ago: dev.twitter.com/discussions/7531. I guess I should talk to twitter.