我正在尝试在运行Amazon Linux的Amazon EC2实例上运行Dashku python脚本。
这是我得到的错误:
[ec2-user@ip-10-231-47-166 ~]$ python dashku_53dc123bc0f9ac740b009af9.py
Traceback (most recent call last):
File "dashku_53dc123bc0f9ac740b009af9.py", line 16, in <module>
requests.post('https://dashku.com/api/transmission', data=json.dumps(payload),headers=headers)
File "/usr/lib/python2.6/site-packages/requests/api.py", line 88, in post
return request('post', url, data=data, **kwargs)
File "/usr/lib/python2.6/site-packages/requests/api.py", line 44, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/lib/python2.6/site-packages/requests/sessions.py", line 335, in request
resp = self.send(prep, **send_kwargs)
File "/usr/lib/python2.6/site-packages/requests/sessions.py", line 438, in send
r = adapter.send(request, **kwargs)
File "/usr/lib/python2.6/site-packages/requests/adapters.py", line 331, in send
raise SSLError(e)
requests.exceptions.SSLError: [Errno 1] _ssl.c:493: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
请注意,我调用sudo yum install requests
的功能并不多,但调用sudo yum upgrade python-requests
确实安装了它。
该脚本可在我的本地计算机上查找,并且根本没有修改:
# Instructions
#
# easy_install requests
# python dashku_53dc123bc0f9ac740b009af9.py
#
import requests
import json
payload = {
"bigNumber": 500,
"_id": "XXXXXX",
"apiKey": "XXXXXX"
}
headers = {'content-type': 'application/json'}
requests.post('https://dashku.com/api/transmission', data=json.dumps(payload),headers=headers)
在我的本地机器上运行它可以正常工作,Dashku会相应更新。
有什么想法吗?感谢。
答案 0 :(得分:0)
不确定这是否是合适的解决方案,但将verify=False
添加到requests.post调用“修复”问题。
requests.post('https://dashku.com/api/transmission', data=json.dumps(payload),headers=headers, verify=False)