ssl - 为什么一个 curl 可以做 https 而另一个不能
问题描述
我运行了一个 curl 查询:curl https://login:password@mywebsite.com/script/
我有几个 curl 可执行文件,一个用 cygwin 安装:
1:
curl 7.59.0 (x86_64-unknown-cygwin) libcurl/7.59.0 OpenSSL/1.0.2o zlib/1.2.11 libidn2/2.0.4 libpsl/0.18.0 (+libidn2/2.0.2) libssh2/1.7.0 nghttp2/1.31.0
Release-Date: 2018-03-14
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp scp sftp smb smbs smtp smtps telnet tftp
Features: AsynchDNS Debug IDN IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz TLS-SRP HTTP2 UnixSockets HTTPS-proxy PSL Metalink
我编译的另外两个:
2 - libcurl-vc14-x86-release-static-ipv6-sspi-winssl:
curl 7.60.0 (i386-pc-win32) libcurl/7.60.0 OpenSSL/1.0.2k WinIDN
Release-Date: 2018-05-16
Protocols: dict file ftp ftps gopher http https imap imaps ldap pop3 pop3s rtsp smb smbs smtp smtps telnet tftp
Features: AsynchDNS IDN IPv6 Largefile SSPI Kerberos SPNEGO NTLM SSL HTTPS-proxy
3 - libcurl-vc14-x86-release-static-ssl-static-ipv6-sspi:
curl 7.60.0 (i386-pc-win32) libcurl/7.60.0 WinSSL WinIDN
Release-Date: 2018-05-16
Protocols: dict file ftp ftps gopher http https imap imaps ldap pop3 pop3s rtsp smb smbs smtp smtps telnet tftp
Features: AsynchDNS IDN IPv6 Largefile SSPI Kerberos SPNEGO NTLM SSL
1 + 3 可以做这个'TSL 请求',2 返回错误信息:
curl: (60) SSL certificate problem: unable to get local issuer certificate
More details here: https://curl.haxx.se/docs/sslcerts.html
curl failed to verify the legitimacy of the server and therefore could not
establish a secure connection to it. To learn more about this situation and
how to fix it, please visit the web page mentioned above.
我在这个问题上找到的所有建议是 - 您必须从服务器获取证书文件并将其存储到本地存储中(或告诉 curl 忽略错误)。
我的问题是 - 为什么这是一个建议的答案,而 1 + 3 可以在没有它的情况下做到这一点?有什么不同?什么有 1 + 3 的共同点,他们可以做 2 不能做的事情?
解决方案
因为...
cygwin 可能已经在本地有一个 CA 存储,作为其主要安装的一部分。它被更多的工具使用,而不仅仅是 curl。
使用“WinSSL”后端构建的 curl 自动使用您的 Windows 安装与操作系统捆绑的 CA 存储。
您使用 OpenSSL 的自定义构建需要 CA 存储来验证远程服务器的证书是否...
推荐阅读
- scala - 将流保存为按元素路径给定的镶木地板
- javascript - 加载页面后是否可以从 TikTok 重新加载嵌入内容?
- python - 我可以从一些 python 代码中获取变量列表及其类型而不运行它吗?
- python - 为什么下面的python代码部分给出属性错误?
- python - 如何通过嵌套列表中的某个索引位置运行 for 循环?
- google-chrome-extension - chrome.downloads.download 立即选择保存目的地
- r - 在数据帧之间进行比较以在两个数据帧中的相同位置找到观察值的 +/- 1
- sql - 超表和“普通”表之间多对多关系的替代方案
- java - 运行 JLink 可执行文件的 Alpine Docker Image
- c - CMake - 与静态和动态库的链接