0

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

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 时却没有?以及如何解决这个问题?

4

1 回答 1

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``.
于 2017-01-13T08:55:08.167 回答