调用apiclient.discovery.build时URL无效和/或缺少SSL证书 [英] Invalid and/or missing SSL certificate for URL when calling apiclient.discovery.build
问题描述
所以我使用 dev_appserver.py
在本地运行我的谷歌端点。
我使用API浏览器来测试应用程序。
我用来创建服务的代码,所以我可以调用API如下:
来自apiclient.discovery import build $ b $ from oauth2client.client import GoogleCredentials
credentials = GoogleCredentials.get_application_default( )
service = build('speech','v1beta1',credentials = credentials)
我收到SSL错误(无效和/或缺少SSL证书),即使当我通过浏览器访问指定的URL时,它也可以正常工作(即绿色挂锁显示出来)。
我不确定发生了什么变化,但是这个工作很好。
我试图禁用SSL检查,但无法执行。
p>完整日志如下:
INFO 2017-01-02 03:12 :02,724 discovery.py:267]请求的网址:GET https://www.googleapis.com/discovery/v1/apis/speech/v1beta1/rest?userIp=0.2.0.3
E RROR 2017-01-02 03:12:03,022 wsgi.py:263]
Traceback(最近一次调用最后一次):
文件/ home / vini / opt / google-cloud-sdk / platform / google_appengine / google / appengine / runtime / wsgi.py,第240行,处理
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
文件/ home / vini / opt / google-cloud / home / vini / home / vini / bin目录下的文件-sdk / platform / google_appengine / google / appengine / runtime / wsgi.py,第299行,位于_LoadHandler
handler,path,err = LoadObject(self._handler)在loadObject
obj = __import __(path [0])
文件/ mnt / opt / google-cloud-sdk / platform / google_appengine / google / appengine / runtime / wsgi.py b117 / home / vini / udacity / cerci-endpoint / api.py,第28行,在< module>
service = build('speech','v1beta1',credentials = credentials)
文件/mnt/b117/home/vini/udacity/cerci-endpoint/lib/oauth2client/_helpers.py,第133行,位于positions_wrapper
返回包装(* args,** kwargs)
文件/mnt/b117/home/vini/udacity/cerci-endpoint/lib/googleapiclient/discovery.py,行222,构建
缓存)
文件/mnt/b117/home/vini/udacity/cerci-endpoint/lib/googleapiclient/discovery.py,第269行,在_retrieve_discovery_doc
resp ,content = http.request(actual_url)
文件/mnt/b117/home/vini/udacity/cerci-endpoint/lib/httplib2/__init__.py,行1609,请求
(response ,content)= self._request(conn,authority,uri,request_uri,method,body,headers,redirections,cachekey)
文件/ mnt / b117 / home / vini / udacity / cerci-endpoint / lib / httplib2 /__init__.py,第1351行,在_request
(response,content)= self._conn_request(conn,request_uri,method,body,headers)
文件/ mnt / b117 / home /vini/udacity/cerci-endpoint/lib/httplib2/__init__.py,第1307行,在_conn_request
response = conn.getresponse()
文件/ home / vini / opt / google-cloud -sdk / platform / google_appengine / google / appengine / dist27 / gae_override / httplib.py,第532行,在getresponse中
raise HTTPException(str(e))
HTTPException:无效和/或缺少SSL证书对于URL:https://www.googleapis.com/discovery/v1/apis/speech/v1beta1/rest?userIp=0.2.0.3
任何想法可能导致这个问题?
我必须安装或更新python使用的SSL证书吗?
根据 App Engine问题13477 ,似乎有些在 App Engine Python SDK中包含的
urlfetch_cacerts.txt
中找到的证书 / gcloud- sdk expired
2017-01-01
。
So I'm running my google endpoint locally with dev_appserver.py
.
I use the API explorer to test the application.
The code I'm using to create the Service, so I can call the API is the following:
from apiclient.discovery import build
from oauth2client.client import GoogleCredentials
credentials = GoogleCredentials.get_application_default()
service = build('speech', 'v1beta1', credentials=credentials)
I receive an SSL error (Invalid and/or missing SSL certificate), even though when I access the stated URL via browser it works fine (that is, the green padlock shows up).
I'm not sure what changed, but this was working fine not long ago.
I tried to disable SSL checking, but was unable to.
Full logs below:
INFO 2017-01-02 03:12:02,724 discovery.py:267] URL being requested: GET https://www.googleapis.com/discovery/v1/apis/speech/v1beta1/rest?userIp=0.2.0.3
ERROR 2017-01-02 03:12:03,022 wsgi.py:263]
Traceback (most recent call last):
File "/home/vini/opt/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 240, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/home/vini/opt/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 299, in _LoadHandler
handler, path, err = LoadObject(self._handler)
File "/home/vini/opt/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 85, in LoadObject
obj = __import__(path[0])
File "/mnt/b117/home/vini/udacity/cerci-endpoint/api.py", line 28, in <module>
service = build('speech', 'v1beta1', credentials=credentials)
File "/mnt/b117/home/vini/udacity/cerci-endpoint/lib/oauth2client/_helpers.py", line 133, in positional_wrapper
return wrapped(*args, **kwargs)
File "/mnt/b117/home/vini/udacity/cerci-endpoint/lib/googleapiclient/discovery.py", line 222, in build
cache)
File "/mnt/b117/home/vini/udacity/cerci-endpoint/lib/googleapiclient/discovery.py", line 269, in _retrieve_discovery_doc
resp, content = http.request(actual_url)
File "/mnt/b117/home/vini/udacity/cerci-endpoint/lib/httplib2/__init__.py", line 1609, in request
(response, content) = self._request(conn, authority, uri, request_uri, method, body, headers, redirections, cachekey)
File "/mnt/b117/home/vini/udacity/cerci-endpoint/lib/httplib2/__init__.py", line 1351, in _request
(response, content) = self._conn_request(conn, request_uri, method, body, headers)
File "/mnt/b117/home/vini/udacity/cerci-endpoint/lib/httplib2/__init__.py", line 1307, in _conn_request
response = conn.getresponse()
File "/home/vini/opt/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://www.googleapis.com/discovery/v1/apis/speech/v1beta1/rest?userIp=0.2.0.3
Any ideas what could be causing this problem?
Do I have to "install" or update the SSL certificates used by python?
According to App Engine issue 13477 it seems that some of the certificates found in urlfetch_cacerts.txt
that is included in the App Engine Python SDK
/ gcloud-sdk
expired 2017-01-01
.
As a temporary workaround, you can replace the contents of <your-cloud-sdk-path>/platform/google_appengine/lib/cacerts/urlfetch_cacerts.txt
with https://curl.haxx.se/ca/cacert.pem
这篇关于调用apiclient.discovery.build时URL无效和/或缺少SSL证书的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!