当我尝试输入所有google时,会发生以下错误:
错误:(gcloud.components.update)无法从服务器获取组件列表。检查网络设置,然后再试一次。Google安装程序现在将退出。按任意键继续。。。
result = func(*args) File "C:\python27_x64\lib\urllib2.py", line 1222, in https_open
return self.do_open(httplib.HTTPSConnection, req) File "C:\python27_x64\lib\urllib2.py", line 1184, in do_open
raise URLError(err) urllib2.URLError: <urlopen error [Errno 10061] No connection could be made because the target machine actively refused it>
有什么想法吗?
发布于 2015-05-26 02:55:24
我在安装时和在另一个先前工作的安装上的某些命令上都有类似的错误。在浏览并添加了一些日志之后,看起来SSL证书验证对于来自Google服务器的组件列表请求失败了:
$ gcloud preview managed-instance-groups ...
You do not currently have this command group installed. Using it requires the installation of components: [preview]
Could not fetch [https://dl.google.com/dl/cloudsdk/release/components-2.json]
<urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:581)>
ERROR: (gcloud) Failed to fetch component listing from server. Check your network settings and try again.
为了解决这个问题(以一种几乎肯定是不可取的方式),我禁用了该单个请求的SSL证书验证。如果您想沿着这条路径走下去,请在
./google-cloud-sdk/lib/googlecloudsdk/core/updater/installers.py:248
发自:
return urllib2.urlopen(req, timeout=TIMEOUT_IN_SEC)
至:
return urllib2.urlopen(req, timeout=TIMEOUT_IN_SEC, context=ssl.SSLContext(ssl.PROTOCOL_TLSv1))
(https://code.google.com/p/google-cloud-sdk/issues/detail?id=143上有一个问题。)
更新: 26/05/15
在我的例子中,这是我安装的OpenSSL版本与Python引用的OpenSSL版本之间的不匹配(这可能是在更新到OpenSSL@1.0.2a-1
之后开始发生的)。
为了解决这个问题,我将我的OpenSSL版本更新为最新版本:
brew update
brew upgrade openssl
然后,我重新安装了Python,引用了这个更新版本的OpenSSL:
brew uninstall python
brew install python --with-brewed-openssl
在此之后,我被Google安装(因为我在那里混了一会儿以找到解决方案;您可能不需要这样做)并从头开始安装:
curl https://sdk.cloud.google.com | bash
我们是黄金!
有关OS中这些OpenSSL问题的进一步阅读,请参阅本文:https://hynek.me/articles/apple-openssl-verification-surprises/
发布于 2016-03-14 22:48:44
TL;博士
cacerts.txt
文件。应该在<google-cloud-sdk>/lib/third_party/httplib2/cacerts.txt
。https://dl.google.com
并导出其证书。cacerts.txt
文件的末尾。您可能还需要make sure your system's openssl version is the same version as the openssl that's used by python, as of jemartti's answer。我试过了但这还不够。我不知道这是否必要。
为达到此解决方案而采取的步骤
在尝试jemartti's answer失败后,我使用了--verbosity debug
标志来跟踪故障点。产出如下:
调试:无法获取"/usr/local/google-cloud-sdk/lib/googlecloudsdk/core/updater/snapshots.py",跟踪(最近一次调用):文件[https://dl.google.com/dl/cloudsdk/channels/rapid/components-v100.0.0.json]行186,在_DictFromURL response = installers.ComponentInstaller.MakeRequest(url,command_path)文件"/usr/local/google-cloud-sdk/lib/googlecloudsdk/core/updater/installers.py",第277行,在MakeRequest返回urlopen_with_cacerts.urlopen(req,文件"/usr/local/google-cloud-sdk/lib/googlecloudsdk/core/util/urlopen_with_cacerts.py",第40行,在urlopen返回orig_urlopen(*args,**kwargs)文件"/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py",第154行中,在urlopen返回opener.open(url,data,文件"/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py",行431,在self._open(req,data)文件"/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py",行449中,在_open '_ open‘中,( req)文件"/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py",行409,在_call_chain result = func(*args)文件"/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py",行1240中,文件"/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py",第1197行,在do_open context=self._context(错误)URLError中:
因此,我打开了/usr/local/google-cloud-sdk/core/util/urlopen_with_cacerts.py
,看到它使用从httplib2.CA_CERTS
获得的cafile
参数调用了httplib2
的urlopen
方法。我添加了一行打印该httplib2.CA_CERTS
的行,输出为:
/usr/local/google-cloud-sdk/lib/third_party/httplib2/cacerts.txt
然后,as described in this answer,这就是我这么做的原因:
cacerts.txt
文件的末尾。作为Mac用户,我还使用了the one-liner described here (出于某些原因产生了与Firefox的证书导出特性不同的证书),以便在我的计算机上保存证书(根据需要替换exmple.com
和example.crt
):
openssl x509 -in <(openssl s_client -connect example.com:443 -prexit 2>/dev/null) -out ~/example.crt
https://stackoverflow.com/questions/30441026
复制相似问题