繁体   English   中英

我如何让 cURL 使用 https

[英]How do i get cURL to use 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是我首先安装它的方法。

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

./configure --with-ssl

最快和最完整的方法是下载curl 源代码并使用--with-ssl标志自行编译 这也将确保您的 curl 和 SSL 库也不会容易受到任何令人讨厌的已知漏洞的攻击。 有使用 SSL 的不安全版本的解决方法,但当然不推荐这样做。

我仍然不知道为什么使用 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 请求造成的。

您的 linux 机器可能没有 libssl 库。 并且 curl 不会因此配置 OpenSSL 并且 https 将不会启用。

首先运行命令:

apt-get install libssl-dev

运行后:

./configure --with-ssl

这对我有用

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM