如何解决 python3 访问 JIRA-REST API 的证书问题?
How to fix certificate issues with python3 accessing JIRA-REST API?
在 Redhat 机器上(Red Hat Enterprise Linux Workstation release 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
此请求 returns 包含实际数据的有效 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 时却没有?以及如何解决这个问题?
如果您想跳过证书验证(不安全),请将验证设置为 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``.
在 Redhat 机器上(Red Hat Enterprise Linux Workstation release 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
此请求 returns 包含实际数据的有效 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 时却没有?以及如何解决这个问题?
如果您想跳过证书验证(不安全),请将验证设置为 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``.