pyN*_*e89 9 python jira python-2.7 jira-rest-api
我在尝试使用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)
Run Code Online (Sandbox Code Playgroud)
我在控制台中收到以下错误消息:
requests.exceptions.SSLError: [Errno 1] _ssl.c:507: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
Run Code Online (Sandbox Code Playgroud)
有什么我可能错过或做错了吗?
谢谢!
小智 13
我遇到了类似的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`.
Run Code Online (Sandbox Code Playgroud)
试试这个 :
from jira.client import JIRA
options = {'server': 'https://jira.companyname.com','verify':False}
jira = JIRA(options)
Run Code Online (Sandbox Code Playgroud)
我知道我在这个答案上已经迟到了,但希望这有助于有人在路上.
为什么你不应该关闭验证
虽然关闭证书验证是最简单的"解决方案",但这不是明智之举.它基本上说,"我不在乎我是否信任你,无论如何我都会把你的所有信息发给你." 这打开了你的中间人攻击.
如果您正在连接到公司的Jira服务器并且它具有TLS/SSL证书,那么您应该对此进行验证.我会问你的IT部门证书在哪里.这可能是贵公司的一些根证书.
如果您在Chrome中连接到服务器(例如),如果通过TLS/SSL保护,则应在地址栏的左侧显示锁定.
你可以Right-Click that lock -> Details -> View Certificate在Chrome中.
好的,我该怎么办?
verify直接为选项提供必要的证书.
jira-python使用Requests了HTTP的东西(见文档).根据Requests文档,
您可以指定证书文件的路径verify.
因此,您可以为您的公司提供根证书,verify如下所示:
jira_options = {
'server': jira_server_name,
'verify': 'path/to/company/root/certificate',
}
Run Code Online (Sandbox Code Playgroud)
如果您使用的是Windows机器(一个安全的假设?),那么根证书将存储在注册表中,并且最好的方法是使用它wincertstore.
在 Windows 系统上,请执行以下操作:-
获得 .cer 文件后,将其添加到 python 脚本中,如下所示:-
jira_options = {
'server': jira_server_name,
'verify': 'path_to_directory_containing_certificate_file/certificate.cer'
}
Run Code Online (Sandbox Code Playgroud)
这应该可以在没有任何安全警告的情况下工作。
| 归档时间: |
|
| 查看次数: |
13381 次 |
| 最近记录: |