【问题标题】:How to fix certificate issues with python3 accessing JIRA-REST API?如何解决 python3 访问 JIRA-REST API 的证书问题?
【发布时间】:2017-05-28 13:56:40
【问题描述】:

在 Redhat 机器上(Red Hat Enterprise Linux Workstation 版本 6.8 (Santiago))我可以向 JIRA 实例发出curl 请求,如下所示:

curl -k -D- -u "user":"password" -X GET -H "Content-Type: application/json" https://some_url/jira/rest/api/2/search?jql=assignee=fritz

此请求返回一个包含实际数据的有效 json。到目前为止,一切都很好。

为了访问和评估来自 json 的信息,我尝试使用 jira-python 以便为 jira json 提供解析器。代码如下:

jira = JIRA('https://some_url/jira', basic_auth=('user','password'))

导致如下错误:

WARNING:root:[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:749) while doing GET https://some_url/jira/rest/api/2/serverInfo [{'params': None, 'headers': {'User-Agent': 'python-requests/2.12.4', 'Accept-Encoding': 'gzip, deflate', 'Accept': 'application/json,*.*;q=0.9', 'Connection': 'keep-alive', 'Cache-Control': 'no-cache', 'Content-Type': 'application/json', 'X-Atlassian-Token': 'no-check'}}]

为什么我在尝试使用 python 访问 JIRA 时出现证书错误,但在使用 curl 时却没有?以及如何解决这个问题?

【问题讨论】:

标签: python json curl jira python-jira


【解决方案1】:

如果您想跳过证书验证(不安全),请将 verify 设置为 False。

jira = JIRA('https://some_url/jira', verify=False, basic_auth=('user','password'))

正如@frlan 指出的那样,最好验证证书。只需检查 JIRA 参数,并指定您的客户端证书进行验证。

解释: https://github.com/pycontribs/jira/blob/5cade37e56612caee36db6310b6e0ef935726944/jira/client.py

 * verify -- Verify SSL certs. Defaults to ``True``.

【讨论】:

  • 不要停用证书检查。如果他们失败了,那是有原因的。
  • @frlan 那可能是什么原因?为什么这很重要?
  • @frlan 说的是对的,会有安全问题。避免中间人攻击。
  • 我猜中间人攻击与我的情况无关。我公司为什么要有人更改 JIRA 票证内容?
  • @Alex SSL 至少在基本层面上不是一门火箭科学,但它增加了很多价值。去做吧。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2017-01-23
  • 2021-01-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-07-04
  • 2012-05-25
相关资源
最近更新 更多