【发布时间】:2016-12-16 13:12:10
【问题描述】:
我有一个带有letsencrypt证书的python3 django网站
一切都很好,除了使用 python 请求到本地地址:
response = requests.post('http://127.0.0.1:8100', data=data)
而且它的行为非常奇怪:
有时我得到 200,但在 supervisorctl restart mywebsite 之后它会抛出 SSLError
然后我做了:
response = requests.post('http://127.0.0.1:8100', data=data, verify=True)
一切都很好,直到我再做一次supervisorctl restart mywebsite,它会抛出 SSLError O_o,现在只适用于
response = requests.post('http://127.0.0.1:8100', data=data)
所以最终的工作代码是:
try:
response = requests.post('http://127.0.0.1:8100', data=data, verify=True)
except:
try:
response = requests.post('http://127.0.0.1:8100', data=data)
except:
response = requests.post('http://127.0.0.1:8100', data=data, verify=False)
显然这不是最好的计划)
非常感谢您的建议
【问题讨论】:
-
请在下面查看我的回答,如果有帮助,请点赞或标记为已接受。谢谢
标签: python ssl ssl-certificate python-requests