Python OAuth2 failing with X509 error

I’ve just spent about 20 minutes trying to authenticate with Twitter using the Python OAuth2 module. I kept on getting an X509 error, specifically:

ssl.SSLError: [Errno 185090050] _ssl.c:343: error:0B084002:x509 certificate routines:X509_load_cert_crl_file:system lib

The solution to this is that the cacerts.txt file in the Python installation is only readable to the root user / wheel group. In order to fix that up, first find the cacerts.txt file:

find /Library/Python/ -name cacerts.txt

Then modify the permissions on the file:

sudo chmod 644 /Library/Python//2.7/site-packages/httplib2-0.7.7-py2.7.egg/httplib2/cacerts.txt

Note that the URL endpoints for twitter on the python-oauth2 Github page are currently wrong. To use the “Twitter Three-legged OAuth Example” change http://twitter.com/oauth/request_token to https://api.twitter.com/oauth/request_token, etc.

Back to blogging

Well, it’s been a loooonnng time since my last blog entry. One of my resolutions for the new year was to do more blogging. Despite this, I haven’t blogged anything for the whole of January. OK, so this stops now. As of today I am starting to blog again. Even if it’s just a short and almost meaningless entry about how I’m going to start blogging again.