【问题标题】:GAE SDK 1.7.4 and InvalidCertificateExceptionGAE SDK 1.7.4 和 InvalidCertificateException
【发布时间】:2012-12-03 16:26:51
【问题描述】:

最近,我将 GAE SDK 升级到了版本。 1.7.4,当我尝试运行开发服务器时,它开始抛出“InvalidCertificateException”。我搜索了这个错误,有些人说它会随着时间的推移而消失,但我的没有。我应该研究什么来解决这个问题?我正在为我的应用程序使用 python 框架 Django,如果这很重要的话。

$ dev_appserver.py ./
INFO     2012-12-16 07:44:31,412 appcfg.py:586] Checking for updates to the SDK.
Traceback (most recent call last):
  File "/usr/local/bin/dev_appserver.py", line 171, in <module>
    run_file(__file__, globals())
  File "/usr/local/bin/dev_appserver.py", line 167, in run_file
    execfile(script_path, globals_)
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver_main.py", line 747, in <module>
    sys.exit(main(sys.argv))
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver_main.py", line 680, in main
    update_check.CheckForUpdates()
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/appcfg.py", line 597, in CheckForUpdates
    runtime=self.config.runtime)
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/appengine_rpc.py", line 391, in Send
    f = self.opener.open(req)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 394, in open
    response = self._open(req, data)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 412, in _open
    '_open', req)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 372, in _call_chain
    result = func(*args)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 1207, in https_open
    return self.do_open(httplib.HTTPSConnection, req)
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/fancy_urllib/fancy_urllib/__init__.py", line 379, in do_open
    url_error.reason.args[1])
fancy_urllib.InvalidCertificateException: Host appengine.google.com returned an invalid certificate (_ssl.c:503: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed): 
To learn more, see http://code.google.com/appengine/kb/general.html#rpcssl

【问题讨论】:

  • 您的根证书似乎不是最新的。 GAE 证书由 Google 证书颁发机构签名 - 因此您的根证书存储需要更新。您是否缺少 Mac 的任何软件更新?
  • @BurhanKhalid 谢谢。我会检查并回复你。
  • @BurhanKhalid 不,一切都更新了,但仍然抛出异常。
  • 我发现的快速解决方法:从已安装的 SDK 中删除文件 google_appengine/lib/cacerts/cacerts.txt。
  • 我不知道为什么,但这个问题自己解决了。现在开发服务器使用 cacerts.txt 没有问题。

标签: python django google-app-engine


【解决方案1】:

我发现的快速解决方法:从已安装的 SDK 中删除文件 google_appengine/lib/cacerts/cacerts.txt

从 GoogleAppEngineLauncher 开始:

GoogleAppEngineLauncher/Contents/Resources/GoogleAppEngineDefault.bundle/Content‌​s/Resources/google_appengine/lib/cacerts/cacerts.txt

编辑#

从 google app engine SDK 1.8.1 开始,此文件已重命名为 urlfetch_cacerts.txt。仍在同一目录中并将其删除 仍然可以解决问题。

–@哈里森

【讨论】:

  • 我猜出于某种原因 cacerts.txt 在升级 SDK 时没有得到更新。修复起来并不难,但仍然困扰着我。
  • 注意: 自 google app engine SDK 1.8.1 起,此文件已重命名为 urlfetch_cacerts.txt。仍然在同一个目录中并删除它仍然可以解决问题。
  • 我得到这个是因为我们的公司使用我们的防火墙做了一个中间人的事情。我将我们的公司 CA 文件添加到上述(两个)文件中,并且成功了。
  • 此修复不适用于 1.8.8,至少在 arch linux 上。有人有什么建议吗?
  • @asitaru 是的,我删除了它以及其余的证书文件,问题仍然存在。我的一位同事昨晚实际上找到了解决这个特殊问题的方法(他也使用了 arch)——我们必须在 ssl.py(在核心 python 文件中)中硬编码以使用 TLSv1 作为 ssl 协议。这是一个巨大的 hack——为了皮特的缘故,我们正在搞乱核心 python 文件!——但它确实有效。如果有人需要更多详细信息,请添加评论,我可以更详细地解释我们的修复。
【解决方案2】:

简洁的答案,截至 2014 年 1 月(刚刚通过 SDK 更新):

rm file /Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/cacerts/urlfetch_cacerts.txt

或者...

cd /Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/cacerts/
rm urlfetch_cacerts.txt

一切又顺利进行了。

您最好也删除“cacerts.txt”(在同一目录中)。否则 sdk 命令行工具也会抛出异常:(

【讨论】:

    【解决方案3】:

    仅供参考:如果您在运行 Mavericks 的 Mac 上,此错误可能是由于使用了 python 2.7.6 或更低版本,它有一个导致此错误的已知错误。

    例如,只要尝试获取任何 SSL 页面,您就会遇到类似的错误:

    pip install requests
    python
    
    >>> import requests
    >>> requests.get("https://github.com")
    

    以上内容会产生相同的 SSL 证书错误。在这种情况下,gcloud(谷歌云 SDK)命令都不起作用。

    升级到 python 2.7.8(或更新的 2.7.X)来解决问题(对我有用)。

    【讨论】:

      【解决方案4】:

      将 Python 从 2.7.3 升级到 2.7.9 为我解决了这个问题。我在 Mac OS X 10.6.8 (Snow Leopard) 上。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-01-23
        • 1970-01-01
        • 2015-08-17
        • 2011-11-25
        • 2018-11-29
        • 2013-05-19
        相关资源
        最近更新 更多