簡體   English   中英

Python:使用urllib3超越SSL驗證

[英]Python: Surpass SSL verification with urllib3

連接到SSL服務器會引發錯誤:

錯誤:14090086:SSL例程:SSL3_GET_SERVER_CERTIFICATE:證書驗證失敗

我正在使用此urllib3 python庫通過以下方法連接到服務器:

urllib3.connectionpool.connection_from_url(['remote_server_url'], maxsize=2)

如何忽略SSL驗證? 還是有另一個步驟可以做到這一點?

謝謝。

通過覆蓋任何ConnectionPool實例的靜態ConnectionCls屬性,您應該能夠強制urllib3使用未經驗證的HTTPSConnection對象。 例如:

from urllib3.connection import UnverifiedHTTPSConnection
from urllib3.connectionpool import connection_from_url

# Get a ConnectionPool object, same as what you're doing in your question
http = connection_from_url(remote_server_url, maxsize=2)

# Override the connection class to force the unverified HTTPSConnection class
http.ConnectionCls = UnverifiedHTTPSConnection

# Make requests as normal...
r = http.request(...)

作為其他參考,您可以檢查一些類似的覆蓋測試

我已經提出了一個問題,以改進我們的文檔以及有關如何以及何時完成此操作的信息。 如果您願意提供幫助,我們將始終感謝您的請求。 :)

您還可以安裝證書庫,這可能會有所幫助

pip install certifi

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM