我正在维护一个使用requests和HTTPS的Python小应用程序。
这个应用程序一直正常工作,直到HTTPS URL中主机名的IP地址发生了更改(合法的)。如果我在浏览器中输入URL,我仍然可以成功检索它。
Python/requests保存ssh's known_hosts的类似物在哪里?如何清除该主机的记录?
$ python --version
Python 2.7.3
$ cat foo.py
import requests
url = "https://somehost/resource.json"
requests.get(url, timeout=5, config={'danger_mode': True})
$ source venv/bin/activate
$ python foo.py
Traceback (most recent call last):
File "foo.py", line 3, in <module>
requests.get(url, timeout=5, config={'danger_mode': True})
File "/home/dfukdev/corsair-scripts/alfred/venv/local/lib/python2.7/site-packages/requests/api.py", line 65, in get
return request('get', url, **kwargs)
File "/home/dfukdev/corsair-scripts/alfred/venv/local/lib/python2.7/site-packages/requests/safe_mode.py", line 39, in wrapped
return function(method, url, **kwargs)
File "/home/dfukdev/corsair-scripts/alfred/venv/local/lib/python2.7/site-packages/requests/api.py", line 51, in request
return session.request(method=method, url=url, **kwargs)
File "/home/dfukdev/corsair-scripts/alfred/venv/local/lib/python2.7/site-packages/requests/sessions.py", line 241, in request
r.send(prefetch=prefetch)
File "/home/dfukdev/corsair-scripts/alfred/venv/local/lib/python2.7/site-packages/requests/models.py", line 641, in send
raise SSLError(e)
requests.exceptions.SSLError: [Errno 1] _ssl.c:504: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
config
已经被移除了吗?我在链接的页面上没有看到它,而我的 Python 却声称它是未知的。而仅仅使用verify=False
似乎并不能解决问题... - codelingVerify
还在。我在脚本中漏了一个第二个reqeuests.get语句,也引发了该错误。然而,config={'danger_mode': True}
不再需要 - 如果我正确地阅读了这个,现在它已经成为默认设置了。感谢你如闪电般快速的回复! - codeling