我正在运行Ubuntu 16.04.4 LTS
。我有以下版本:
root@e816b85d954d:/# http --debug
HTTPie 0.9.9
Requests 2.9.1
Pygments 2.1
Python 2.7.12 (default, Dec 4 2017, 14:50:18)
[GCC 5.4.0 20160609]
/usr/bin/python
Linux 4.4.0-116-generic
root@e816b85d954d:/# curl --version
curl 7.47.0 (x86_64-pc-linux-gnu) libcurl/7.47.0 GnuTLS/3.4.10 zlib/1.2.8 libidn/1.32 librtmp/2.3
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp smb smbs smtp smtps telnet tftp
Features: AsynchDNS IDN IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz TLS-SRP UnixSockets
Run Code Online (Sandbox Code Playgroud)
curl
工作正常:
$ curl https://mysite
Run Code Online (Sandbox Code Playgroud)
但是httpie
失败了:
root@e816b85d954d:/# http https://mysite
http: error: SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590) while doing GET request to URL: https://mysite
Run Code Online (Sandbox Code Playgroud)
为什么会是这种情况?
错误消息非常直接。它告诉您 Web 服务器包含一个有问题的 SSL 证书(很可能是因为它是自签名的、已过期等)。
您应该能够使用以下--verify
选项停止检查证书有效性:
--验证验证
设置为“是”以检查主机的 SSL 证书。您还可以将路径传递给私有证书的 CA_BUNDLE 文件。您还可以设置 REQUESTS_CA_BUNDLE 环境变量。
所以,设置--verify no
就足够了。
# http --verify no https://...
/usr/lib/python2.7/dist-packages/urllib3/connectionpool.py:794: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.org/en/latest/security.html
[...]
Run Code Online (Sandbox Code Playgroud)
不过,最好始终建议使用有效的 SSL 证书。
归档时间: |
|
查看次数: |
1596 次 |
最近记录: |