gpt4 book ai didi

Python 请求 "certificate verify failed"

转载 作者:太空狗 更新时间:2023-10-29 17:08:00 24 4
gpt4 key购买 nike

我正在维护一个使用请求 + HTTPS 的 Python 迷你应用程序。

在 HTTPS URL 中主机名的 IP 地址更改(合法)之前,该应用程序一直有效。如果我将浏览器指向该 URL,我可以很好地检索它。

Python/requests 在哪里保存 ssh 的 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

最佳答案

您使用的是旧版本的请求。如果您升级到 2.0 并且您的站点存在证书不匹配,您将获得更有用的消息,您可以通过指定能够验证中间证书的系统证书来修复它。您也可以只请求不按照 Andre 的建议验证您的证书。

关于Python 请求 "certificate verify failed",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18999517/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com