刚刚看到了javayou提到了可以在windows下使用的curl命令,
http://www.javayou.com/html/diary/showlog.vm?sid=2&log_id=13985
于是下载了支持ssl的curl来使用:
下载连接为: http://www.execve.net/curl/curl-7.17.0-win32-ssl.zip
解压到D:\Programs\curl-7.17.0
下载OpenSSL组件:
http://618119.com/OpenSSL/libeay32.dll
http://618119.com/OpenSSL/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
标签: 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
你好,
我在linux下使用curl也出现了问题。
问题如下:
在linux或winodws浏览器运行含有curl的php文件是正常的(所谓得前台运行)。但是在linux后台用php命令执行相同得php文件却一直报“段错误”。在测试中,发现只有https的地址才会出现此问题,http则正常运行的。
服务器得配置是:
redhat linux AS4
TOMCAT5.5
APACHE2.0.59
PHP5.2.6
希望能得到你得帮助。谢谢。
Reply
lizongbo reply on 一月 8th, 2009:
不好意思,我没在linux下试过,不过原理应该都是一样的,即导入配置客户端和服务端都可以信任的根证书。
谢谢。我再从这方面继续查找下。
Reply
非常感谢.我总是感觉自己在加密和认证这里基础知识不过关!
我试了windows下的curl 是好用的.我的命令行里不是这个参数.
-cacert ca.crt 查了一下 help应该是这个参数.
–cacert ca.crt
linux下的help里也是这个参数. 但我没有实际进行测试.
再次感觉. 8-)
Reply
发现这个blog程序对发的消息有改动.
连续两个减号(英文字符)
--
会被改为 一个减号!!!
-
--cacert ca.crt
这样写才是正确的参数。 但不能复制。你需要输入英文字符的减号。喝喝。
Reply
lizongbo reply on 二月 15th, 2009:
嗯,确实这样,不知道是wordpress还是其插件做了什么处理,
一些url也替换成了escaped_anchor这样的东西,我懒得处理了。