【发布时间】:2015-06-05 15:25:27
【问题描述】:
请帮助我理解为什么我无法通过 https 成功 curl 这个网址:
我正在使用带有 curl 7.22.0、libcurl 7.22.0 和 OpenSSL 1.0.1-4ubuntu5.25 的 Ubuntu 12.04.5
$ curl -v https://www.onevanilla.com/
* About to connect() to www.onevanilla.com port 443 (#0)
* Trying 199.83.128.4... connected
* successfully set certificate verify locations:
* CAfile: none
CApath: /etc/ssl/certs
* 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, verify that the CA cert is OK. Details:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
* Closing connection #0
curl: (60) SSL certificate problem, verify that the CA cert is OK. Details:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
所以我尝试手动获取证书:
$ openssl s_client -connect www.onevanilla.com:443 </dev/null | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > /tmp/www.onevanilla.com.pem
然后:
$ curl -v --cacert /tmp/www.onevanilla.com.pem https://www.onevanilla.com
但我得到相同的结果:
* About to connect() to www.onevanilla.com port 443 (#0)
* Trying 199.83.128.4... connected
* successfully set certificate verify locations:
* CAfile: /tmp/www.onevanilla.com.pem
CApath: /etc/ssl/certs
* 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, verify that the CA cert is OK. Details:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
* Closing connection #0
curl: (60) SSL certificate problem, verify that the CA cert is OK. Details:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
我可以用 openssl 验证证书:
$ openssl s_client -host www.onevanilla.com -port 443 -CApath /etc/ssl/certs
这会返回Verify return code: 0 (ok)
为了确定,我还运行了sudo update-ca-certificates --fresh,但没有运气。
所以在我看来,证书是有效的(未过期,主机名与 CN 匹配),但我永远无法使用 curl 获得成功的响应(当然,除非我使用 -k 或 --insecure 选项)。谁能解释一下?
【问题讨论】:
标签: ssl curl https ssl-certificate