2017-01-02 3 views
16

dev_appserver.py으로 로컬로 Google Endpoint를 실행하고 있습니다. API 탐색기를 사용하여 응용 프로그램을 테스트합니다.apiclient.discovery.build를 호출 할 때 URL에 대한 SSL 인증서가 잘못되었거나 누락되었습니다.

내가 서비스를 만드는 데 사용하고, 그래서이 API를 호출 할 수있는 코드는 다음

from apiclient.discovery import build 
from oauth2client.client import GoogleCredentials 
credentials = GoogleCredentials.get_application_default() 
service = build('speech', 'v1beta1', credentials=credentials) 

내가 SSL 오류 (잘못된 및/또는 누락 된 SSL 인증서)를받을 경우에도 불구하고 브라우저에서 명시된 URL에 액세스하면 정상적으로 작동합니다 (녹색 자물쇠가 표시됨).

나는 무엇이 바뀌 었는지 모르겠지만 오래 전에 괜찮 았어.

SSL 검사를 사용하지 않으려했지만 시도 할 수 없었습니다. 아래

전체 로그 :

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 

이 문제의 원인이 될 수 있는지 어떤 아이디어가?

"설치"하거나 파이썬에서 사용하는 SSL 인증서를 업데이트해야합니까?

+1

오늘 아침부터이 문제가 발생합니다 .2016 년 --2017 년 변경 될 수 있습니다. – allsyed

답변

26

App Engine issue 13477에 따르면 App Engine Python SDK/gcloud-sdk에 포함되어 urlfetch_cacerts.txt에있는 인증서 중 일부는 2017-01-01 만료 된 것으로 보인다. 임시 해결 방법으로

, 당신 8 월 2017 년으로 최근 같은 지역 dev에 환경이 오류를 얻었다 https://curl.haxx.se/ca/cacert.pem

+0

명시된 인증서를 삭제하면 실제로 문제가 해결됩니다. 대단히 감사합니다. 이것은 나를 미치게했다. – diogovk

+0

위대한 @ 다니엘스! 그것은 작동합니다. 감사. 그러나 나는 그들이 아직 그것을 고치지 않았다는 것에 놀랐다. – neaGaze

-1

<your-cloud-sdk-path>/platform/google_appengine/lib/cacerts/urlfetch_cacerts.txt의 내용을 대체 할 수있는 수정은 모든 URL을 가져올 수 호출 및 인증서 표시의 힘 유효성 검사를 업데이트하는 것입니다 :

urlfetch.fetch(url=url, validate_certificate=True) 

gcloud certs (MacOS)를 건드리지 않아도됩니다. Issuing an HTTPS request을 참조하십시오.

+0

이것은 나를 위해 문제를 해결하지 못했다. – svpino

0

MacOS에서 @danielx를 사용하여 답변을 작성하려면이 방법이 유용합니다. 당신이 curl가 설치되어 있지 않은 경우에 당신은 download 인증서를 이동 수동

cd /Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/cacerts 
mv urlfetch_cacerts.txt urlfetch_cacerts.bup 
curl -o urlfetch_cacerts.txt -k https://curl.haxx.se/ca/cacert.pem 

수 있습니다 나를 위해 인증서의 경로했다 :

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

그것을 업데이트하려면, 나는 다음 단계를 사용 위의 폴더로 이동하십시오. 이미 실행중인 App Engine dev 서버를 다시 시작하는 것을 잊지 마십시오.

관련 문제