HTTPException:网址无效和/或缺少SSL证书:https://accounts.google.com/o/oauth2/token

时间:2017-01-03 04:13:01

标签: python-2.7 google-app-engine ssl httpexception google-earth-engine

当我通过Google AppEngine呼叫Google地球引擎(GEE)Python API时,它会抛出HTTPException,其中显示“ HTTPException:无效和/或缺少网址的SSL证书:https://accounts.google.com/o/oauth2/token ”。该项目在新年假期之前运行良好,但是当我在昨天进行测试时突然爆发而我的代码没有任何变化。

The detailed error information

3 个答案:

答案 0 :(得分: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

答案 1 :(得分:2)

the tracker for this GAE issue上,维护人员提供了一种解决方法:

  

作为临时解决方法,您可以将过期的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

答案 2 :(得分:0)

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

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

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

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

检查cacerts的存储位置。我在

中找到了它们
C:\Program Files (x86)\Google\google_appengine\lib\cacerts

其他report它在:

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

瞧!