10

当我通过 Google AppEngine 调用 Google Earth Engine (GEE) Python API 时,它会抛出一个 HTTPException,上面写着“ HTTPException: invalid and/or missing SSL certificate for url: https://accounts.google.com/o/oauth2 /令牌“。该项目在元旦之前运行良好,但我昨天测试时突然爆发,我自己的代码没有任何变化。

详细的错误信息

4

3 回答 3

6

我在使用 App Engine 的 python 脚本中也遇到了同样的问题。几天前运行良好,accounts.google.com 的证书有效期至 2017 年 3 月 9 日

File "/Users/QQQ/Documents/Developpements/ae-python-project/app/user_spreadsheet_auth.py", line 55, in _get_service
  service = build('sheets', 'v4', http=http_auth)
File "/Users/QQQ/Documents/Developpements/ae-python-project/libs/oauth2client/_helpers.py", line 133, in positional_wrapper
  return wrapped(*args, **kwargs)
File "/Users/QQQ/Documents/Developpements/ae-python-project/libs/googleapiclient/discovery.py", line 222, in build
  cache)
File "/Users/QQQ/Documents/Developpements/ae-python-project/libs/googleapiclient/discovery.py", line 269, in _retrieve_discovery_doc
  resp, content = http.request(actual_url)
File "/Users/QQQ/Documents/Developpements/ae-python-project/libs/oauth2client/transport.py", line 159, in new_request
  credentials._refresh(orig_request_method)
File "/Users/QQQ/Documents/Developpements/ae-python-project/libs/oauth2client/client.py", line 744, in _refresh
  self._do_refresh_request(http)
File "/Users/QQQ/Documents/Developpements/ae-python-project/libs/oauth2client/client.py", line 775, in _do_refresh_request
  body=body, headers=headers)
File "/Users/QQQ/Documents/Developpements/ae-python-project/libs/oauth2client/transport.py", line 282, in request
  connection_type=connection_type)
File "/Users/QQQ/Documents/Developpements/ae-python-project/libs/httplib2/__init__.py", line 1609, in request
  (response, content) = self._request(conn, authority, uri, request_uri, method, body, headers, redirections, cachekey)
File "/Users/QQQ/Documents/Developpements/ae-python-project/libs/httplib2/__init__.py", line 1351, in _request
  (response, content) = self._conn_request(conn, request_uri, method, body, headers)
File "/Users/QQQ/Documents/Developpements/ae-python-project/libs/httplib2/__init__.py", line 1307, in _conn_request
  response = conn.getresponse()
File "/Users/QQQ/google-cloud-sdk/platform/google_appengine/google/appengine/dist27/gae_override/httplib.py", line 532, in getresponse
  raise HTTPException(str(e))
HTTPException: Invalid and/or missing SSL certificate for URL: https://accounts.google.com/o/oauth2/token

编辑:看起来这个问题已经在几个小时前报告了:https ://code.google.com/p/googleappengine/issues/detail?id=13477

于 2017-01-03T09:52:22.337 回答
2

此 GAE 问题的跟踪器上,维护人员提供了一种解决方法:

作为临时解决方法,您可以将过期的 urlfetch_cacerts.txt 替换为https://curl.haxx.se/ca/cacert.pem

在 linux 上,您可以使用以下命令: wget https://curl.haxx.se/ca/cacert.pem -O {Python SDK 的根目录}/lib/cacerts/urlfetch_cacerts.txt

于 2017-01-16T21:45:34.570 回答
0

对于 Windows,由于 SDK 存储在管理员只读区域中,因此我分两步使用 Windows 文件资源管理器,而不是脚本。

首先将https://curl.haxx.se/ca/cacert.pem下载到一个文件夹,例如 Downloads。

curl https://curl.haxx.se/ca/cacert.pem > urlfetch_cacerts.txt

您还可以使用浏览器下载文件并重命名。

检查您的 cacerts 的存储位置。我发现他们在

C:\Program Files (x86)\Google\google_appengine\lib\cacerts

其他人报告它:

C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\lib\cacerts\urlfetch_cacerts.txt 

使用管理员凭据,将文件 urlfetch_cacerts.txt 重命名为其他名称。

然后将下载的文件cacerts.pem复制到

C:\Program Files (x86)\Google\google_appengine\lib\cacerts

并将其重命名为 urlfetch_cacerts.txt

瞧!

于 2017-06-14T22:38:57.997 回答