## ssl verification error in python [python ssl 憑證錯誤] 在Python中,使用requests等套件進行爬蟲時如果遇到ssl verification error ` (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1016)')))` 此時可以嘗試透過更新certifi或是自行安裝ca檔來進行排除 ### 1. 更新certifi `pip install --upgrade certifi urllib3` ### 2. 自行安裝 如果狀況未能排除,則需要透過手動把該網頁憑證加入本地憑證目錄中 1. 找到憑證位置 ```python! import certifi print(certifi.where()) ``` 2. 下載網頁憑證(先到目標網頁利用F12、隱私與安全性、檢視憑證)  知道憑證頒發機構後,至機構網址進行下載  這邊以TWCA為例(不同發行機構要找到目標檔案的容易度不同:cry:),到ssl 憑證搜尋的地方尋找,並輸入網址(不要https、不要\後的文字)(root only)  選擇憑證鍊  下載後檔案如下:  3. 以文字編輯器開啟uca.cer (沒用文字編輯器會變成請問要不要安裝憑證的畫面)  4. 以文字檔開啟`certifi.where()`,將憑證貼至檔案底部! ## 就完成了!
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up