过去使用python代码从SoftLayer进行API调用,现在会出错。
import SoftLayer
conn = SoftLayer.create_client_from_env(username='',api_key='')
allParents = conn.call('Account','getAllTopLevelBillingItems')
allParents[0] # returns the first billing_Item as a dict
它曾经工作,但现在出现以下错误消息:
result = conn['SoftLayer_Account'].getAllTopLevelBillingItems(mask=objectMask)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/SoftLayer/API.py", line 363, in call_handler
return self(name, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/SoftLayer/API.py", line 331, in call
return self.client.call(self.name, name, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/SoftLayer/API.py", line 227, in call
return self.transport(request)
File "/usr/local/lib/python2.7/dist-packages/SoftLayer/transports.py", line 164, in __call__
raise exceptions.TransportError(0, str(ex))
SoftLayer.exceptions.TransportError: TransportError(0): [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590)
答案 0 :(得分:1)
这可能与此SSL InsecurePlatform error when using Requests package
有关Softlayer已经记录了有关SSL错误的信息:
在Python 2.7.9以下的Python版本中,由于创建SSL连接的不安全性,请求已开始发出安全警告(InsecurePlatformWarning)。要解决此问题,请升级到Python 2.7.9+或按照此处的说明进行操作:https://stackoverflow.com/a/29099439。
请确保您使用的是Python 2.7.9或supirior,然后重试
答案 1 :(得分:0)
我几个月前发现,如果安装了python certifi软件包,这将导致SoftLayer API流量无法通过证书验证。
我从未发现原因,我只是避免了创建该依赖项的软件包。在我的情况下,我试图安装花。