我嘗試使用 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'))
uj5u.com熱心網友回復:
您應該嘗試添加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 證書,并忽略主機名不匹配和/或過期的證書,這將使您的應用程式容易受到中間人 (MitM) 攻擊。設定verify為False在本地開發或測驗期間可能很有用。
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/394886.html
