刚刚看到了javayou提到了可以在windows下使用的curl命令,
http://www.javayou.com/html/diary/showlog.vm?sid=2&log_id=13985
于是下载了支持ssl的curl来使用:
下载连接为: http://www.execve.net/--escaped_anchor:5d46c217459898ec8972155e71509b97--/curl-7.17.0-win32-ssl.zip
解压到D:\Programs\curl-7.17.0
下载OpenSSL组件:
http://618119.com/--escaped_anchor:5e81b97d5483ae9cc4d410a319552617--/libeay32.dll
http://618119.com/--escaped_anchor:5e81b97d5483ae9cc4d410a319552617--/libssl32.dll
将libssl32.dll和libeay32.dll复制到D:\Programs\curl-7.17.0,
否则运行curl.exe会被提示:
—————————
curl.exe - 无法找到组件
—————————
没有找到 libeay32.dll,因此这个应用程序未能启动。重新安装应用程序可能会修复此问题。
—————————
确定
—————————
—————————
curl.exe - 无法找到组件
—————————
没有找到 libssl32.dll,因此这个应用程序未能启动。重新安装应用程序可能会修复此问题。
—————————
确定
—————————
(参考: http://618119.com/archives/2007/10/26/15.html)
如果需要连接的网站使用的证书不是操作系统已经信任的证书,则需要指定ca根证书文件.
并且服务器的证书CN必须与url里的host一致,否则无法下载.
测试命令示例如下:
curl https://lizongbo.618119.com/ –cacert ca.crt
D:\Programs\curl-7.17.0>curl https://www.google.com/
<HTML><HEAD><meta http-equiv=”content-type” content=”text/html;charset=utf-8″>
<TITLE>302 Moved</TITLE></HEAD><BODY>
<H1>302 Moved</H1>
The document has moved
<A href=”http://www.google.com”>here</A>.
</BODY></HTML>
D:\Programs\curl-7.17.0>curl https://618119.com/
curl: (60) SSL certificate problem, verify that the CA cert is OK. Details:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify faile
d
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). The default
bundle is named curl-ca-bundle.crt; 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.
D:\Programs\curl-7.17.0>curl https://lizongbo.618119.com/ –cacert ca.crt
curl: (51) SSL: certificate subject name ‘618119.com’ does not match target host name ‘lizongbo.618119.com’
Related posts
Tags: cacert, curl, libssl32.dll, openssl
你好
我现在使用CURL出现一点问题
正好在你这里找到了原因
非常感谢
就是如果需要连接的网站使用的证书不是操作系统已经信任的证书,则需要指定ca根证书文件.
并且服务器的证书CN必须与url里的host一致,否则无法下载.::
这点
出现的抱错就是curl https://www.618119.com/出现的错误一样
但是我不知道如何解决这个错误,使用–cacert ca.crt指定方式也不行
我在FEDORA环境下没有问题,将CURL移植到板子上就不行了,在板子上也可以下载到那种不需要证书的网页
我的EMAIL:willie.lw@gmailcom
希望得到您的指点 谢谢
[Reply]
to lw:
你需要找到网站证书的根证书,并且导出成crt文件,才能使用–cacert ca.crt 这样的参数.
而这个文件,除了系统内置的,其余的通常需要到 ca机构的网站去下载,
例如szca的根证书下载页面为: http://www.szca.gov.cn:8081/jsp/web/Certificate.do
我没有你的那种环境,我所测试的根证书也是我自己生成的,所以无法判断其它环境下的具体原因.
[Reply]