我正在尝试在 Ubuntu 11.04 上安装 Rails 环境。当我启动命令 rvm install 1.9.2 --with-openssl-dir=/usr/local
时,收到以下错误:
curl : (1) Protocol https not supported or disabled in libcurl
如何解决?
--with-openssl-dir=/usr/local
(即仅使用 rvm install 1.9.2
)会发生什么?
sudo apt-get install curl
)。尝试 curl -o "google.html" https://google.com
检查是否支持 HTTPS。
RCurl
有相同的错误消息。
得到了 windows 的答案 HERE,它在那里说:
curl -XPUT 'http://localhost:9200/api/twittervnext/tweet'
糟糕,第一次尝试并已经出现错误:
curl: (1) Protocol 'http not supported or disabled in libcurl
这个错误的原因有点愚蠢,当您使用单引号作为命令时,Windows 不喜欢它。所以正确的命令是:
curl –XPUT "http://localhost:9200/api/twittervnext/tweet"
我遇到了这个问题,结果发现导致问题的 https
之前有一个空格。 " https://"
与 "https://"
看起来已经有很多答案了,但我面临的问题是双引号。两者之间有区别:
“
和
"
将第一个双引号更改为第二个对我有用,下面是示例 curl:
curl -X PUT -u xxx:xxx -T test.txt "https://test.com/test/test.txt"
我在尝试为 ruby 安装 rvm 时遇到了同样的问题。找到解决方案:在 root 的下载文件夹中提取 curl (tar) 后。
cd /root/Downloads/curl # step-1
./configure --with-ssl # step-2
make # step-3
make install # step-4 (if not root, use sudo before command)
就我而言,libcurl 最初不支持 HTTPS 协议。为了找出支持哪些协议,哪些不支持,我使用命令检查了 curl 版本:
curl --version
它提供的信息如下: curl 7.50.3 (x86_64-apple-darwin15.6.0) libcurl/7.50.3 SecureTransport zlib/1.2.5
协议:dict file ftp ftps gopher http imap imaps ldap ldaps pop3 pop3s rtsp smb smbs smtp smtps telnet tftp Features:IPv6 Largefile NTLM NTLM_WB SSL libz UnixSockets
恰好不支持 https 协议的地方。
然后我重新安装 curl 并使用以下命令安装它(解压后):
./configure --with-darwinssl (在mac中启用ssl通信) make make test sudo make install
经过几分钟的工作,问题解决了!
然后我重新运行 curl version 命令,它显示:
curl 7.50.3 (x86_64-apple-darwin15.6.0) libcurl/7.50.3 SecureTransport zlib/1.2.5
协议:dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp smb smbs smtp smtps telnet tftp 特性:IPv6 Largefile NTLM NTLM_WB SSL libz UnixSockets
HTTPS协议出现了!
最后,当您遇到 curl 问题时,可以参考一个有用的站点。 https://curl.haxx.se/docs/install.html
我只是通过将 'http://webname...'
更改为 "http://webname..."
来解决它
注意引号。它应该是双引号 ("
) 而不是单引号 ('
)。
使用标志 --with-darwinssl 解决了这个问题
使用 curl 源代码转到文件夹
在这里下载https://curl.haxx.se/download.html
sudo ./configure --with-darwinssl
make
make install
重新启动您的控制台,它就完成了!
这在 libcurl 常见问题解答条目“Protocol xxx not supported or disabled in libcurl”中特别提到。
为了您的高兴,我也在这里嵌入了解释:
当将 URL 传递给 curl 使用时,它可能会响应不支持或禁用特定协议。此错误消息的特殊表述方式是因为 curl 在内部没有区分是否不支持特定协议(即从未添加任何知道如何使用该协议的代码)或是否明确禁用它。 curl 可以构建为仅支持给定的一组协议,然后将禁用或不支持其余协议。请注意,如果您传递一个拼写错误的协议部分,如“htpt://example.com”,或者在不太明显的情况下,如果您在协议部分前面加上一个空格,如“http://example”,也会发生此错误.com/”。
我的问题是由未显示的 UTF 符号引起的。我从浏览器复制链接(在我的例子中是 nginx track)并在剪贴板中得到以下内容:
$ echo -n "https://sk.ee/upload/files/ESTEID-SK_2015.pem.crt" | hexdump -C
00000000 e2 80 8b 68 74 74 70 73 3a 2f 2f 73 6b 2e 65 65 |...https://sk.ee|
00000010 2f 75 70 6c 6f 61 64 2f 66 69 6c 65 73 2f 45 53 |/upload/files/ES|
00000020 54 45 49 44 2d 53 4b 5f 32 30 31 35 2e 70 65 6d |TEID-SK_2015.pem|
00000030 2e 63 72 74 |.crt|
问题出在 https
之前的序列 0xe2 0x80 0x8b
中。此序列是以 UTF-8 编码的 ZERO WIDTH JOINER。
在 https 网站上使用 curl 时遇到同样的错误,例如
curl https://api.dis...
正如 ganesh 所指出的,这是因为我的 curl 版本没有启用 ssl。返回并使用 ssl 下载版本,它工作正常。
我刚刚使用指向 openssl 1.0.2g 库文件夹和包含文件夹的配置选项重新编译了 curl,但我仍然收到此消息。当我在 curl 上执行 ldd 时,它没有显示它使用 libcrypt.so
或 libssl.so
,所以我认为这一定意味着即使 make
和 make install
成功且没有错误,但是 curl 没有 HTTPS支持?配置和制作如下:
./configure --prefix=/local/scratch/PACKAGES/local --with-ssl=/local/scratch/PACKAGES/local/openssl/openssl-1.0.2g --includedir=/local/scratch/PACKAGES/local/include/openssl/openssl-1.0.2g
make
make test
make install
我应该提到 libssl.so.1
在 /local/scratch/PACKAGES/local/lib
中。目前还不清楚 --with-ssl
选项应该指向那里还是指向 openssl 安装程序放置 openssl.cnf 文件的目录。我选择了后者。但如果它应该是前者,那么 make 应该会失败,并出现找不到库的错误。
在 url 中指定协议可能会解决您的问题。
我有一个类似的问题(使用 curl php 客户端时):
我传递的是 domain.com 而不是 sftp://domain.com 这导致了这个令人困惑的错误:
libcurl 中不支持或禁用协议“http”,耗时 0 秒。
不定期副业成功案例分享
curl "http://localhost:3030/messages/" -H "Content-Type: application/json" --data-binary "{ \"name\":\"Curler\", \"text\": \"Hello from the command line\" }"
而不是curl "http://localhost:3030/messages/" -H "Content-Type: application/json" --data-binary '{ "name":"Curler", "text": "Hello from the command line" }'
...注意错误部分的单引号和未转义的双引号。new_url=$( echo $url | tr -d \" )