为什么我收到“libcurl 中不支持或禁用协议 http”?

为什么我收到“libcurl 中不支持或禁用协议 http”?

我正在尝试使用以下命令将存储库添加到我的 OpenSUSE Leap 42.3(在 WSL 上运行)。

sudo zypper addrepo https://download.opensuse.org/repositories/devel:languages:php/openSUSE_Leap_42.3/devel:languages:php.repo

我收到以下错误。

下载(curl)错误 'https://download.opensuse.org/repositories/devel:语言:php/openSUSE_Leap_42.3/devel:语言:php.repo': 错误代码:错误的 URL 错误消息:libcurl 中不支持或禁用协议 http

当我使用 https 作为协议时,我发现错误消息谈论 http 的事实令人困惑,而且更令人困惑的是,curl --version提示 https 的输出是受支持的协议。

curl 7.37.0 (x86_64-suse-linux-gnu) libcurl/7.37.0 OpenSSL/1.0.2j zlib/1.2.8 libidn/1.28 libssh2/1.4.3
协议: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp scp sftp smtp smtps telnet tftp
功能: 异步 DNS GSS 协商 IDN IPv6 大文件 NTLM NTLM_WB SSL libz TLS-SRP

使用zypper info libssl43,我得到以下输出。

Information for package libssl43:
---------------------------------
Repository     : oss
Name           : libssl43
Version        : 2.5.3-6.1
Arch           : x86_64
Vendor         : openSUSE
Installed Size : 360.0 KiB
Installed      : Yes
Status         : up-to-date
Source package : libressl-2.5.3-6.1.src
Summary        : An SSL/TLS protocol implementation
Description    :
    LibreSSL is an open-source implementation of the Secure Sockets Layer
    (SSL) and Transport Layer Security (TLS) protocols. It derives from
    OpenSSL and intends to provide a more secure implementation.

的输出zypper info libcrypto41如下。 (libcrypto41 是 libssl43 的依赖项。)

Information for package libcrypto41:
------------------------------------
Repository     : oss
Name           : libcrypto41
Version        : 2.5.3-6.1
Arch           : x86_64
Vendor         : openSUSE
Installed Size : 2.0 MiB
Installed      : Yes (automatically)
Status         : up-to-date
Source package : libressl-2.5.3-6.1.src
Summary        : An SSL/TLS protocol implementation
Description    :
    The "crypto" library implements a wide range of cryptographic
    algorithms used in various Internet standards. The services provided
    by this library are used by the LibreSSL implementations of SSL, TLS
    and S/MIME, and they have also been used to implement SSH, OpenPGP,
    and other cryptographic standards.

如何使用 https URL?我可以改用 http,但我不想走那条路。

答案1

我发现主题:zypper https url:libcurl 中不支持或禁用协议“http”,其中包含一个链接主题: /home/~/.cache/kioexec/krun/####_# 中的缓存文件?如何避免?

按照这些帖子中的内容,我尝试了curl https://download.opensuse.org/repositories/devel:languages:php/openSUSE_Leap_42.3/devel:languages:php.repo,它输出以下内容。

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>301 Moved Permanently</title>
</head><body>
<h1>Moved Permanently</h1>
<p>The document has moved <a href="http://download.opensuse.org/repositories/devel:languages:/php/openSUSE_Leap_42.3/devel:languages:php.repo">here</a>.</p>
<hr>
<address>Apache/2.2.34 (Linux/SUSE) Server at download.opensuse.org Port 443</address>
</body></html>

因此,https://download.opensuse.org/repositories/devel:languages:php/openSUSE_Leap_42.3/devel:languages:php.repo被重定向到http://download.opensuse.org/repositories/devel:languages:/php/openSUSE_Leap_42.3/devel:languages:php.repo,并且由于重定向是从 https:// 到 http://,因此 Zypper 后面不会跟随。

简而言之,服务器尚未使用 https:// URL 工作,临时解决方法是使用 http:// URL。我的 OpenSuse 42.3 安装没有任何问题。

答案2

作为解决方法,您可以手动添加(以 root 身份)以下文件/etc/zypp/repos.d/php.repo及其内容

[devel_languages_php]
name=devel:languages:php (openSUSE_Leap_42.3)
type=rpm-md
baseurl=http://download.opensuse.org/repositories/devel:/languages:/php/openSUSE_Leap_42.3/
gpgcheck=1
gpgkey=http://download.opensuse.org/repositories/devel:/languages:/php/openSUSE_Leap_42.3/repodata/repomd.xml.key
enabled=1

这是上面 URL 的内容:http://download.opensuse.org/repositories/devel:/languages:/php/openSUSE_Leap_42.3/devel:languages:php.repo

相关内容