开发者

Looking to solve the SSL error in Google Plus API command-line Python starter kit running on localhost

I'm trying to get the command-line Python starter for Google Plus API working, but after the authentication has completed, I run into this error:

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

I'm running Python 2.7 on Ubuntu 11.04. The API uses httplib2 to send requests. I'm running the starter kit of开发者_运维技巧f of localhost.


Here's the terminal dump:

Traceback (most recent call last):
File "/home/vijay/Downloads/google-plus-python-starter/cli/plus_cli.py", line 114, in <module>
main()
File "/home/vijay/Downloads/google-plus-python-starter/cli/plus_cli.py", line 62, in main
credentials = authorize_self(settings.CLIENT_ID,settings.CLIENT_SECRET)
File "/home/vijay/Downloads/google-plus-python-starter/cli/plus_cli.py", line 48, in authorize_self
credentials = run(flow, storage)
File "/home/vijay/Downloads/googleapi/oauth2client/tools.py", line 146, in run
credential = flow.step2_exchange(code)
File "/home/vijay/Downloads/googleapi/oauth2client/client.py", line 698, in step2_exchange
headers=headers)
File "/home/vijay/Downloads/googleapi/httplib2/__init__.py", line 1436, in request
(response, content) = self._request(conn, authority, uri, request_uri, method, body, headers, redirections, cachekey)
File "/home/vijay/Downloads/googleapi/httplib2/__init__.py", line 1188, in _request
(response, content) = self._conn_request(conn, request_uri, method, body, headers)
File "/home/vijay/Downloads/googleapi/httplib2/__init__.py", line 1123, in _conn_request
conn.connect()
File "/home/vijay/Downloads/googleapi/httplib2/__init__.py", line 890, in connect
self.disable_ssl_certificate_validation, self.ca_certs)
File "/home/vijay/Downloads/googleapi/httplib2/__init__.py", line 76, in _ssl_wrap_socket
cert_reqs=cert_reqs, ca_certs=ca_certs)
File "/usr/lib/python2.7/ssl.py", line 344, in wrap_socket
ciphers=ciphers)
File "/usr/lib/python2.7/ssl.py", line 119, in __init__
ciphers)
ssl.SSLError: [Errno 185090050] _ssl.c:336: error:0B084002:x509 certificate routines:X509_load_cert_crl_file:system lib`

Things I've tried to get this working:

  1. Manually copied cacerts.txt from http://httplib2.googlecode.com/hg-history/6525cadfde53279479533c1235e2661f5c147afc/python2/httplib2/cacerts.txt to /usr/lib/python2.7/dist-packages/httplib2
  2. Updated httplib2 to latest version 0.7.1
  3. Disabled SSL in all httplib2 calls made from the files in the starter kit (plus_cli.py), using httplib2.Http(disable_ssl_certificate_validation=True)

I'm out of ideas, and need your help in solving this.


In case someone has a similar error (error code 185090050):

I had the same thing using the Dropbox API. The problem was that the file containing the cert info could not be loaded; in my case it was because of pyInstaller, which is not compatible with the pkg_resources used by the Dropbox SKD. Just edit the line that assigns the certificate in Dropbox's rest.py to the following:

TRUSTED_CERT_FILE =  'trusted-certs.crt'

instead of using pkg_resources, and distribute the trusted certs list along with the application. The Python SSL library displays very opaque error messages, but really, it's just a missing file thing...


I had the same problem with a different script and think the problem is the following:

  1. when installing the google api for python one (more or less) automatically also installs a version of httplib2
  2. this version is buggy. For one thing the cacerts.txt file (which on my system is located below

/usr/local/lib/python2.7/dist-packages/httplib2-0.8-py2.7.egg/httplib2 )

is only root readable. But the actual problem seems to be that the package looks for a "ca_certs_locatermodule" which doesn't exist.

Since my system has httplib2 installed as an own package anyway (as does yours it seems) (re)moving this buggy version of httplib2 (i.e. the folder

/usr/local/lib/python2.7/dist-packages/httplib2-0.8-py2.7.egg )

solved the problem. To trace down this kind of problem you can run

strace -o io.txt python your_script.py

and look in the file io.txt for lines containing "ENOENT" (No such file or directory).


which python-httplib2 version are you using?

I solved this by using python-httplib2 0.7.1-2 (Debian Sid) instead of the one within google-api-python-client.


This looks like this bug: http://code.google.com/p/google-api-python-client/issues/detail?id=58


PyInstaller and Dropbox API give same error (error code 185090050) !

In this case we must "tell" PyInstaller to load rest.py from Dropobox API -> make a file in PyInstaller hooks named: hooks-rest.py and put 1 there ! Then we must "tell" rest.py where trusted certificates are -> TRUSTED_CERT_FILE = os.path.join('location of trusted-certs.crt', 'trusted-certs.crt').


I was facing a similar problem using the gdata client (along with Pyinstaller) and the simplest fix is to add a file named "ca_certs_locater.py" in the httplib2 module and adding in the following code in the file:

def get():
    return "cacerts.txt"

It's a simple case of Pyinstaller not finding the file, and the designers of httplib2 allow for the case of adding in your own path to the cacerts via the method I highlighted above.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜