寻求解决在本地主机上运行的 Google Plus API 命令行 Python 入门工具包中的 SSL 错误

发布于 2024-12-05 02:20:34 字数 2579 浏览 2 评论 0原文

我正在尝试获取Google Plus API 的命令行 Python 启动器 工作,但身份验证完成后,我遇到此错误:

ssl.SSLError: [Errno 185090050] _ssl.c:336:错误:0B084002:x509 证书例程:X509_load_cert_crl_file:系统 lib

我在 Ubuntu 11.04 上运行 Python 2.7。 API 使用 httplib2 发送请求。我正在 localhost 上运行入门工具包。


这是终端转储:

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`

我尝试过的工作:

  1. http://httplib2.googlecode.com/hg-history/6525cadfde53279479533c1235e2661f5c147afc/python2/httplib2/cacerts.txt 手动复制 cacerts.txt/usr/lib/python2.7/dist-packages/httplib2
  2. httplib2 更新到最新版本 0.7.1
  3. 在从入门工具包中的文件进行的所有 httplib2 调用中禁用 SSL (plus_cli.py),使用 httplib2.Http(disable_ssl_certificate_validation=True)

我没有主意,需要你的帮助来解决这个问题。

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 off 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

浪漫之都 2024-12-12 02:20:34

如果有人遇到类似的错误(错误代码 185090050):

我使用 Dropbox API 时遇到了同样的问题。问题是无法加载包含证书信息的文件;就我而言,这是因为 pyInstaller 与 Dropbox SKD 使用的 pkg_resources 不兼容。只需将 Dropbox 的 rest.py 中分配证书的行编辑为以下内容:

TRUSTED_CERT_FILE =  'trusted-certs.crt'

而不是使用 pkg_resources,并将受信任的证书列表与应用程序一起分发。 Python SSL 库显示非常不透明的错误消息,但实际上,这只是一个丢失文件的事情......

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...

我不咬妳我踢妳 2024-12-12 02:20:34

我在不同的脚本上遇到了同样的问题,我认为问题如下:

  1. 当为 python 安装 google api 时,(或多或少)会自动安装 httplib2 的一个版本,
  2. 这个版本有问题。一方面, cacerts.txt 文件(在我的系统上位于

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

只能 root 读取。但实际的问题似乎是该包寻找不存在的“ca_certs_locatermodule”。

由于我的系统已将 httplib2 作为自己的软件包安装(看起来与您的系统一样)(重新)移动这个有缺陷的 httplib2 版本(即文件夹

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

解决了问题。要追踪此类问题,您可以运行

strace -o io.txt python your_script.py

并在文件 io.txt 中查找包含“ENOENT”(没有此类文件或目录)的行。

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).

海的爱人是光 2024-12-12 02:20:34

您使用的是哪个 python-httplib2 版本?

我通过使用 python-httplib2 0.7.1-2 (Debian Sid) 而不是 google-api-python-client 中的解决了这个问题。

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.

許願樹丅啲祈禱 2024-12-12 02:20:34

PyInstaller 和 Dropbox API 给出相同的错误(错误代码 185090050)

在这种情况下,我们必须“告诉”PyInstaller 从 Dropbox API 加载rest.py ->在 PyInstaller 挂钩中创建一个名为:
hooks-rest.py 并将 1 放在那里!然后我们必须“告诉”rest.py 可信证书在哪里 ->
TRUSTED_CERT_FILE = os.path.join('trusted-certs.crt 的位置', 'trusted-certs.crt')

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').

花桑 2024-12-12 02:20:34

我使用 gdata 客户端(以及 Pyinstaller)遇到了类似的问题,最简单的解决方法是在 httplib2 模块中添加一个名为“ca_certs_locater.py”的文件,并在文件中添加以下代码:

def get():
    return "cacerts.txt"

这是 Pyinstaller 的一个简单情况找不到该文件,并且 httplib2 的设计者允许通过我上面突出显示的方法添加您自己的 cacerts 路径。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文