红联Linux门户
Linux帮助

curl不支持https

发布时间:2016-03-03 11:31:10来源:linux网站作者:Timsley

如果curl是默认安装的话,是不支持https,当你在使用libcurl去访问https时,就会报以下的错误:
* Protocol https not supported or disabled in libcurl
* Unsupported protocol


可以通过下面的命令查看curl现在支持哪些协议:

curl不支持https

可以看到现在curl是不支持https的。

如果curl要支持https,就必须先安装openssl,安装方法可以看下面的链接:
http://www.linuxdiyf.com/linux/18580.html


安装完openssl,接下来就是重新配置安装curl:

我的配置环境如下
ubuntu版本:14.04
CURL版本:curl-7.30.0.tar.gz(https://curl.haxx.se/download.html)
openssl版本:openssl-1.0.1q.tar.gz(http://www.openssl.org/)

1)tar zxvf curl-7.30.0.tar.gz
2)cd curl-7.30.0/
3)./configure –with-ssl=/usr/local/ssl(我这里没有配置prefix选项,直接将curl安装到默认的目录/usr/local)
config之后,会有以下信息打出:

curl不支持https

4)make
make的时候可能会出现以下错误:
../lib/.libs/libcurl.so: undefined reference to `SSLv2_client_method’

刚开始我用的curl-7.22.0.tar.gz,后面出了上面这个问题后,以为是版本不对,又升级到curl-7.30.0,其实都一样,还是make出错。
网上说是因为openssl配置的时候不支持sslv2。
http://stackoverflow.com/questions/8206546/undefined-symbol-sslv2-method
后来搜索之后,借鉴以下方法解决了:
http://stackoverflow.com/questions/8287515/problems-building-libcurl-7-21-2-on-ubuntu-11-10-hiphop

实际是vim lib/ssluse.c,修改如下:

curl不支持https

重新make,通过了。

5)make install

最后查看curl支持的协议,可以看到现在已经支持https协议了。
curl -V

curl不支持https


本文永久更新地址:http://www.linuxdiyf.com/linux/18581.html