[英]SSL3 Certificate Verify Failed when Connecting to JIRA API Using Python
我目前在嘗試使用 Python2.7 和 JIRA REST API ( http://jira-python.readthedocs.org/en/latest/ ) 連接到 JIRA 時遇到錯誤。
當我執行以下操作時:
from jira.client import JIRA
options = {
'server': 'https://jira.companyname.com'
}
jira = JIRA(options)
我在控制台中收到以下錯誤消息:
requests.exceptions.SSLError: [Errno 1] _ssl.c:507: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
有什么我可能錯過或做錯的事情嗎?
謝謝!
我遇到了類似的 SSL 證書驗證錯誤,並查看了“JIRA”方法定義,可以關閉驗證。
:param options: Specify the server and properties this client will use. Use a dict with any
of the following properties:
* server -- the server address and context path to use. Defaults to ``http://localhost:2990/jira``.
* rest_path -- the root REST path to use. Defaults to ``api``, where the JIRA REST resources live.
* rest_api_version -- the version of the REST resources under rest_path to use. Defaults to ``2``.
* verify -- Verify SSL certs. Defaults to ``True``.
* resilient -- If it should just retry recoverable errors. Defaults to `False`.
嘗試這個 :
from jira.client import JIRA
options = {'server': 'https://jira.companyname.com','verify':False}
jira = JIRA(options)
我知道我在這個答案上遲到了,但希望這對未來的人有所幫助。
為什么不應該關閉驗證
雖然關閉證書驗證是最簡單的“解決方案”,但這並不是一個明智的做法。 它本質上是說,“我不在乎我是否信任你,無論如何我都會把我所有的信息都發給你。” 這為中間人攻擊打開了大門。
如果您要連接到您公司的 Jira 服務器並且它具有 TLS/SSL 證書,則您應該對此進行驗證。 我會問你的 IT 部門那個證書在哪里。 它可能在貴公司的某個根證書中。
如果您在 Chrome 中連接到服務器(例如),如果它是通過 TLS/SSL 保護的,它應該在地址欄的左手角顯示一個鎖。
您可以Right-Click that lock -> Details -> View Certificate
在 Chrome 中Right-Click that lock -> Details -> View Certificate
。
好的,那我該怎么辦?
直接向verify
選項提供必要的證書。
jira-python
使用 HTTP Requests
(見文檔) 。 根據Requests 文檔,您可以在verify
指定證書文件的路徑。
因此,您可以在verify
為您的公司提供根證書,如下所示:
jira_options = {
'server': jira_server_name,
'verify': 'path/to/company/root/certificate',
}
如果您使用的是 Windows 機器(安全假設?),則該根證書存儲在注冊表中,獲得它的最佳方法是使用wincertstore
。
在 Windows 系統上,請執行以下操作:-
獲得 .cer 文件后,將其添加到 python 腳本中,如下所示:-
jira_options = {
'server': jira_server_name,
'verify': 'path_to_directory_containing_certificate_file/certificate.cer'
}
這應該可以在沒有任何安全警告的情況下工作。
只需安裝 python-certifi-win32 模塊,這應該可以幫助您輕松解決這些錯誤
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.