use*_*008 3 python windows error-handling ssl
我尝试使用 python requests 库,但收到此错误 我大部分时间在 Windows 10 中使用 psiphon VPN,并在调用后收到以下错误requests.get('[API URL]')
Exception has occurred: SSLError
HTTPSConnectionPool(host='api.github.com', port=443): Max retries exceeded with url: /user (Caused by SSLError(SSLError(1, '[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:997)')))
During handling of the above exception, another exception occurred:
During handling of the above exception, another exception occurred:
File "C:\Users\Hessam\Desktop\QWE.py", line 3, in <module>
r = requests.get('https://api.github.com/user', auth=('user', 'pass'))
Run Code Online (Sandbox Code Playgroud)
您应该尝试添加verify=False到您的请求中:
import requests\nr = requests.get('https://api.github.com/user', verify=False)\nRun Code Online (Sandbox Code Playgroud)\nrequests验证 HTTPS 请求的 SSL 证书,就像 Web 浏览器一样。默认情况下,启用 SSL 验证,requests如果\xe2\x80\x99s 无法验证证书,则会抛出 SSLError。
根据您的具体情况,您的 VPN 上的 SSL 证书很可能存在问题。
\n请注意,当verify设置为时False,requests将接受服务器提供的任何 TLS 证书,并忽略主机名不匹配和/或过期的证书,这将使您的应用程序容易受到中间人 (MitM) 攻击。设置verify为False在本地开发或测试期间可能很有用。
| 归档时间: |
|
| 查看次数: |
14137 次 |
| 最近记录: |