如何让cURL使用https

时间:2015-02-28 13:59:43

标签: linux ubuntu curl https

我在Ubuntu 14.04.2 LTS上。已安装cURL但不包含HTTPS作为其将使用的协议。

例如:

curl https://npmjs.org/install.sh | sh

给了我这个:

curl: (1) Protocol https not supported or disabled in libcurl

检查curl -V导致:

Protocols: dict file ftp gopher http imap pop3 rtsp smtp telnet tftp
Features: IPv6 Largefile

该列表中缺少HTTPS ...因此,如何安装支持HTTPS的cURL?

哦,sudo apt-get install curl就是我在第一时间安装它所做的。

2 个答案:

答案 0 :(得分:1)

您的curl版本未经SSL支持编译。它实际上是在配置阶段传递的标志:

./configure --with-ssl

最快捷,最完整的方式是使用--with-ssl标记下载curl sourcescompile it yourself。这也将确保您的curl和SSL库不会受到任何令人讨厌的已知漏洞的攻击。有使用不安全版本的SSL的解决方法,但当然不推荐使用。

答案 1 :(得分:1)

我仍然不知道为什么使用Aptitude安装不支持HTTPS的版本但是从头开始构建技巧:

git clone https://github.com/bagder/curl.git
sudo apt-get build-dep curl
cd curl
./buildconf
./configure
make
sudo make install 

现在curl -V产生

Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp smb smbs smtp smtps telnet tftp
Features: IDN IPv6 Largefile NTLM NTLM_WB SSL libz TLS-SRP UnixSockets

哦,我首先需要这个的原因是因为NVM在尝试下载Node版本或者使用nvm ls-remote获取可用版本列表时给了我N / A.这是因为cURL不适用于HTTPS请求。