【问题标题】:How do I enable https support in libcurl?如何在 libcurl 中启用 https 支持?
【发布时间】:2013-10-01 15:45:46
【问题描述】:

当我尝试$ brew update 时出现错误:

error: Protocol https not supported or disabled in libcurl while accessing https://github.com/mxcl/homebrew/info/refs?service=git-upload-pack

但是,当我$ curl --version 时,我看到了:

curl 7.21.4 (x86_64-apple-darwin12.2.0) libcurl/7.21.4 OpenSSL/0.9.8y zlib/1.2.5 libidn/1.20
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp smtp smtps telnet tftp 
Features: IDN IPv6 Largefile NTLM SSL libz 

除非我错过了什么,否则我觉得这很好。请注意,https 列在协议列表中。

$ which curl 产生可疑响应:

/usr/local/php5/bin/curl

嗯嗯...也许brew 正在使用不同的curl(比如/usr/bin/curl 的那个)。让我们看看:

$ /usr/bin/curl --version

curl 7.24.0 (x86_64-apple-darwin12.0) libcurl/7.24.0 OpenSSL/0.9.8y zlib/1.2.5
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp smtp smtps telnet tftp 
Features: AsynchDNS GSS-Negotiate IPv6 Largefile NTLM NTLM_WB SSL libz 

好的,这显然是 curl 的不同安装,但它还在协议列表中列出了 https,并且那里也有 OpenSSL 信息。

顺便说一句:如果我尝试在我的机器上使用带有任何 git 存储库的 https URL,我会遇到同样的错误。

问题:

  1. 如何确定brew 正在使用的curl 的路径?
  2. 如何在libcurl 中启用对https 的支持?

更新:我能够通过以下 deltheil 的方法确定git(和brew)正在使用的libcurl.4.dylib 的路径。路径是:

/usr/lib/libcurl.4.dylib (compatibility version 6.0.0, current version 6.1.0)

所以我尝试了这个:

$ brew install curl --with-libssh2

幸运的是 curl 在非 SSL URI 上可用,所以它确实安装了。它没有符号链接到/usr/local,但这对我来说很好(我认为)。所以我这样做了:

$ cd /usr/lib
$ mv libcurl.4.dylib libcurl.4.dylib.bk
$ ln -s /usr/local/Cellar/curl/7.30.0/lib/libcurl.4.dylib libcurl.4.dylib
$ brew update

但它仍然给我这个错误:

error: Protocol https not supported or disabled in libcurl while accessing https://github.com/mxcl/homebrew/info/refs?service=git-upload-pack

所以现在问题完全变成了:如何在libcurl 中启用对https 的支持?

【问题讨论】:

    标签: git libcurl homebrew


    【解决方案1】:

    这对我有用:

    重新安装 curl 并使用以下命令安装(解压后):

    $ ./configure --with-darwinssl    
    $ make    
    $ make test    
    $ sudo make install
    

    当您运行命令“curl --version”时,您会注意到 https 协议现在存在于“协议”下。

    如果您遇到 curl 问题,这是一个有用的网站:https://curl.haxx.se/docs/install.html

    【讨论】:

      【解决方案2】:

      我在 OSX 上遇到了这个问题。问题是 usr/local/bin 中重复的 curl 和 curl.config 文件与 usr/bin 中的相同两个文件冲突。我删除了 local/bin 中的第一组,之后终端开始工作。

      【讨论】:

        【解决方案3】:

        如何确定 brew 使用的 curl 的路径?

        Homebrew 使用/usr/bin/curl,即Mac OS X 附带的版本,如您所见here

        话虽如此,正如您所说,您的问题可能与与 git 链接并用于 http://https:// 的 libcurl 版本有关。

        执行which git 以确定您正在使用哪个版本(我的安装在/usr/local 下)。

        然后扫描使用的共享库如下:

        $ otool -L /usr/local/git/libexec/git-core/git-http-push | grep curl
        /usr/lib/libcurl.4.dylib
        

        /usr/local/ 替换为与您的git 对应的安装目录。

        由于您的git exec 使用的 libcurl 版本缺少 HTTPS 支持,这将告诉您这个版本是什么以及它的安装位置。

        【讨论】:

        • 谢谢@deltheil,你让我走到了一半。我已经根据当前进度更新了问题。
        • 肯定有问题,因为git 与支持 https 的系统 libcurl 正确链接。话虽如此,您应该永远,永远修改/usr/bin/usr/lib等下的系统文件。我建议您运行brew doctor 并检查此Github HTTPS cloning errors 页面。
        • 或者,您可能希望通过 Homebrew 正确安装 git 并使用 with-brewed-curl 选项,以便 git 使用来自 brew 的 curl,这取决于 darwinssl 以获得 SSL 支持。
        • 我运行了brew doctor,它列出了一堆已安装但未安装的文件 brewed 或其他...我删除了所有这些文件,除了一些我知道不是的 PHP5 配置文件任何麻烦,它的工作!非常感谢您的帮助。
        猜你喜欢
        • 2016-08-23
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-08-06
        • 2012-03-24
        • 2017-01-10
        • 2017-09-14
        • 2020-01-22
        相关资源
        最近更新 更多