如何在 VS Code 环境中修复 "Exception has occurred: SSLError HTTPSConnectionPool"
how to fix "Exception has occurred: SSLError HTTPSConnectionPool" in VS Code environment
我尝试使用 python 请求库,但出现此错误
我在 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'))
您应该尝试将 verify=False
添加到您的请求中:
import requests
r = requests.get('https://api.github.com/user', verify=False)
requests
验证 HTTPS 请求的 SSL 证书,就像 Web 浏览器一样。默认情况下,启用 SSL 验证,如果无法验证证书,requests
将抛出 SSLError。
在您的具体情况下,您的 VPN 上的 SSL 证书很可能有问题。
请注意,当 verify
设置为 False
时,requests
将接受服务器提供的任何 TLS 证书,并且将忽略主机名不匹配的 and/or 过期证书,这将使您的应用程序容易受到中间人 (MitM) 攻击。将 verify
设置为 False
在本地开发或测试期间可能会有用。
我尝试使用 python 请求库,但出现此错误
我在 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'))
您应该尝试将 verify=False
添加到您的请求中:
import requests
r = requests.get('https://api.github.com/user', verify=False)
requests
验证 HTTPS 请求的 SSL 证书,就像 Web 浏览器一样。默认情况下,启用 SSL 验证,如果无法验证证书,requests
将抛出 SSLError。
在您的具体情况下,您的 VPN 上的 SSL 证书很可能有问题。
请注意,当 verify
设置为 False
时,requests
将接受服务器提供的任何 TLS 证书,并且将忽略主机名不匹配的 and/or 过期证书,这将使您的应用程序容易受到中间人 (MitM) 攻击。将 verify
设置为 False
在本地开发或测试期间可能会有用。