我正在尝试将 httpie 与 JIRA REST API 一起使用。
该命令失败并显示“SSLError:主机名
bash-3.2$ http https://jira.mongodb.org/rest/api/2/search?jql=assignee=bob
http: error: SSLError: hostname 'jira.mongodb.org' doesn't match either of '*.mongodb.com', 'mongodb.com'
我的理解是,如果 SSL 证书无效, requests
通常应该抛出该错误。 该消息似乎暗示该证书适用于 *.mongodb.com,jira.mongodb.org 不属于该证书。
但是,相同的命令可以通过 CurL 正常工作,没有 SSL 警告:
bash-3.2$ curl -v https://jira.mongodb.org/rest/api/2/search?jql=assignee=free
* Adding handle: conn: 0x7fbe2b003a00
* Adding handle: send: 0
* Adding handle: recv: 0
* Curl_addHandleToPipeline: length: 1
* - Conn 0 (0x7fbe2b003a00) send_pipe: 1, recv_pipe: 0
* About to connect() to jira.mongodb.org port 443 (#0)
* Trying 54.221.213.229...
* Connected to jira.mongodb.org (54.221.213.229) port 443 (#0)
* TLS 1.1 connection using TLS_RSA_WITH_AES_256_CBC_SHA
* Server certificate: jira.mongodb.org
* Server certificate: Go Daddy Secure Certification Authority
* Server certificate: Go Daddy Class 2 Certification Authority
> GET /rest/api/2/search?jql=assignee=free HTTP/1.1
> User-Agent: curl/7.30.0
> Host: jira.mongodb.org
> Accept: */*
>
< HTTP/1.1 200 OK
* Server Apache-Coyote/1.1 is not blacklisted
< Server: Apache-Coyote/1.1
< Vary: Accept-Encoding
< Cache-Control: no-cache, no-store, no-transform
< Content-Type: application/json;charset=UTF-8
< Date: Fri, 26 Sep 2014 02:14:22 GMT
< X-AREQUESTID: 134x54195573x2
< Transfer-Encoding: chunked
< X-AUSERNAME: anonymous
< Set-Cookie: atlassian.xsrf.token=ASGJ-NC06-6R0X-EKH7|4d65065ad638afb4fe7edb9b04e81379cc315e06|lout; Path=/
<
* Connection #0 to host jira.mongodb.org left intact
{"startAt":0,"maxResults":50,"total":0,"issues":[]}
此外,它在我的浏览器(Chrome)中也可以正常加载,并且没有给出 SSL 警告。
请对可能发生的事情有任何想法吗?
这与 SNI 有关。 您需要安装额外的依赖项,如果您执行“pip install requests[security]”,您将获得这些依赖项
使用 K-9 Mail 从我的 Android 设备发送。 请原谅我的简短。
有同样的问题,但我可以获得工作请求的唯一方法是将验证设置为 False。 我尝试升级请求并安装请求[安全],甚至将验证设置为证书文件。
我也有这个问题。 我需要升级requests[security]
和httpie
:
pip install --upgrade requests[security]
pip install --upgrade httpie
这些错误应该在依赖 Python 3.6+ 的较新 HTTPie 版本中消失。
最有用的评论
这与 SNI 有关。 您需要安装额外的依赖项,如果您执行“pip install requests[security]”,您将获得这些依赖项
使用 K-9 Mail 从我的 Android 设备发送。 请原谅我的简短。