【问题标题】:cURL unable to use curl-ca-bundle.crt when accessing SSL访问 SSL 时 cURL 无法使用 curl-ca-bundle.crt
【发布时间】:2014-07-25 14:16:59
【问题描述】:

我在 Windows 上尝试通过 SSL 使用 cURL,但遇到了我绝对无法弄清楚的证书问题。

例如,这是我尝试运行的示例。

$ curl "https://google.com" --ntlm -v --negotiate -u USERNAME:PASSWORD --proxy "PROXY" --cert "c:\temp\curl-ca-bundle.crt"
* Adding handle: conn: 0x147ce88
* Adding handle: send: 0
* Adding handle: recv: 0
* Curl_addHandleToPipeline: length: 1
* - Conn 0 (0x147ce88) send_pipe: 1, recv_pipe: 0
* About to connect() to proxy PROXY port 8080 (#0)
*   Trying 192.168.134.80...
* Connected to PROXY (PROXY_IP) port 8080 (#0)
* Establish HTTP proxy tunnel to google.com:443
> CONNECT google.com:443 HTTP/1.1
> Host: google.com:443
> User-Agent: curl/7.30.0
> Proxy-Connection: Keep-Alive
>
< HTTP/1.1 200 Connection established
<
* Proxy replied OK to CONNECT request
* unable to use client certificate (no key found or wrong pass phrase?)
* Closing connection 0
curl: (58) unable to use client certificate (no key found or wrong pass phrase?)

尝试使用 --cacert 而不是 --cert 会产生以下消息 -

* Adding handle: conn: 0x130cdf8
* Adding handle: send: 0
* Adding handle: recv: 0
* Curl_addHandleToPipeline: length: 1
* - Conn 0 (0x130cdf8) send_pipe: 1, recv_pipe: 0
* About to connect() to proxy PROXY port 8080 (#0)
*   Trying 192.168.135.80...
* Connected to PROXY (PROXY_IP) port 8080 (#0)
* Establish HTTP proxy tunnel to google.com:443
> CONNECT google.com:443 HTTP/1.1
> Host: google.com:443
> User-Agent: curl/7.30.0
> Proxy-Connection: Keep-Alive
>
< HTTP/1.1 200 Connection established
<
* Proxy replied OK to CONNECT request
* successfully set certificate verify locations:
*   CAfile: c:\temp\curl-ca-bundle.crt
  CApath: none
* SSLv3, TLS handshake, Client hello (1):
* SSLv3, TLS handshake, Server hello (2):
* SSLv3, TLS handshake, CERT (11):
* SSLv3, TLS alert, Server hello (2):
* SSL certificate problem: unable to get local issuer certificate
* Closing connection 0
curl: (60) SSL certificate problem: unable to get local issuer certificate
More details here: http://curl.haxx.se/docs/sslcerts.html

curl performs SSL certificate verification by default, using a "bundle"
 of Certificate Authority (CA) public keys (CA certs). If the default
 bundle file isn't adequate, you can specify an alternate file
 using the --cacert option.
If this HTTPS server uses a certificate signed by a CA represented in
 the bundle, the certificate verification probably failed due to a
 problem with the certificate (it might be expired, or the name might
 not match the domain name in the URL).
If you'd like to turn off curl's verification of the certificate, use the
-k (or --insecure) option.

我拥有的curl-ca-bundle.crt 来自here,这是几分钟前更新的。我确保该文件没有被 Windows 阻止。

对于它的价值,我在公司代理和防火墙后面。我已经阅读了有关此问题的所有内容,但不知道下一步该做什么。我确实意识到我可以忽略 SSL,但我想不惜一切代价避免这种情况。

【问题讨论】:

  • 如果您从浏览器连接并检查服务器证书。它与您从另一个连接(来自另一个网络)获得的结果相同吗?
  • Google 有自己的 CA。下载 Google Internet Authority G2 并将其用作 CA(您需要将其从 ASN.1/DER 转换为 PEM)。没有必要相信 CA 动物园。如果 Steffen 是正确的,那么您可以使用 openssl s_client -connect google.com:443 -CAfile google-ca.pem 验证证书是伪造的。 如果 s_client 没有以Verify 0 (OK) 结束,那么你正在受到攻击。
  • @Bruno:我认为你在做某事。从 Chrome 检查有效的 SSL 证书表明它是从我们的代理服务器之一颁发的。
  • @user3238014 虽然没有直接关系,但可能与this的原因大致相同。
  • @jww:不幸的是,我在 Windows 机器上运行 openssl 要么崩溃,要么给我一个文件 errno:9。这两个我目前都无法修复。

标签: windows curl ssl


【解决方案1】:

对于它的价值,我在公司代理和防火墙后面。我已经阅读了有关此问题的所有内容,但不知道下一步该做什么。我确实意识到我可以忽略 SSL,但我想不惜一切代价避免这种情况。

我建议防火墙进行 SSL 拦截,即它充当中间人。要检查加密连接,它会将其拆分为两个加密连接,但当然它无法使用原始证书对浏览器和代理之间的连接进行签名。因此,它将创建一个由特定于防火墙的 CA 签名的新证书。您需要将此 CA 添加到您的 CA 包中,否则验证将失败。

有关更多详细信息,您可以尝试使用 Web 浏览器访问目标站点并检查签署服务器证书的 CA,或向您的系统管理员询问 SSL 拦截的详细信息。

【讨论】:

    猜你喜欢
    • 2016-03-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-26
    • 2014-11-26
    • 2012-06-17
    • 2018-09-13
    • 1970-01-01
    相关资源
    最近更新 更多