如何在Mac OS X上启用curl SSL?

17

我在Mac OS X 10.11.2上使用终端,并且无法处理任何https请求。我总是收到以下错误:

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

我尝试过这个,但是出现了“错误的目录”提示:

./configure --with-ssl=/usr/local/ssl

任何建议都将有所帮助。

编辑:

这是当我尝试使用ssl安装时遇到的错误:

configure: error: OpenSSL libs and/or directories were not found where specified!

解决方案:

对于 Mac OS X 10.6 或更高版本,请使用以下内容启用 SSL:

./configure --with-darwinssl

1
你尝试过 curl --ssl 吗? - danielmhanover
安装的libcurl版本不支持此操作。我尝试通过终端安装Homebrew,但由于是https请求,无法进行安装。 - Ben
1
在你的情况下,./configure 文件的位置在哪里? - Bista
curl -V 将列出支持的协议(除了版本号)。 - Daryl Spitzer
7个回答

39

Homebrew团队最近删除了cURL配方的所有安装选项,这意味着你现在将无法使用brew install curl --with-openssl。而是使用brew install curl-openssl,确保首先卸载旧版本brew uninstall curl


2
这是我需要的信息,它不应该在页面底部!其他人都说要使用“--with-openssl”选项,但这已经不可能了。此外,我还必须关闭我的防病毒软件,因为它阻止连接以便下载cURL包。 - Jono
3
补充一点,完成后需要关闭终端并重新打开。我浪费了一个小时。 - Witterquick
3
FYI - 2021年建议使用brew install curl安装openssl curl,请参见此讨论链接:https://github.com/Homebrew/discussions/discussions/1268 - its_a_paddo

13

以下步骤有助于解决问题: (注意:libcurl将会被重新编译)

# First simply remove curl and try reinstall with openssl:
brew rm curl && brew install curl --with-openssl # Rerun 
如果不行的话,请按以下步骤下载并重新构建libcurl,这些步骤帮助我解决了这个问题。
# Download curl from : https://curl.haxx.se/download.html
wget https://curl.haxx.se/download/curl-7.58.0.zip  # or, wget https://curl.haxx.se/download/curl-*.*.*
unzip curl-7.58.0.zip  # or, unzip curl-*.*.*

./configure --with-darwinssl  # However for Linux(ubuntu): ./configure --with-ssl 
make
sudo make install  # Rerun the program

这是一个比Ben的更好的答案,并且应该被接受。(Vadym Tyemirov的答案对我没有用。) - Daryl Spitzer
1
(对于那些同样缺乏shell技能的人来说...)在运行./configure --with-darwinssl之前,您需要进入解压后的curl目录。 :-) - Spookytheboy
当运行 ./configure --with-darwinssl 时出现错误。configure: error: C 编译器无法创建可执行文件 - SHUMING LU

7

解决方案:

对于 Mac OS X 10.6 及更高版本,请使用以下方法启用 SSL:

./configure --with-darwinssl

  • 没有找到文件或目录:./configure。该怎么办?我的赏金:https://dev59.com/OVkS5IYBdhLWcg3w6qXU#39300838?noredirect=1#comment65998448_39300838
- Bista
2
请问在Mac上curl安装在哪里? - JoaMika

5

1

如果有人在2021年及以后使用Xcode 12+尝试通过命令行构建项目,不想依赖于 'brew' 或其他包管理器......

从github获取curl源代码后,我遇到了“./configure:没有这样的文件或目录”问题。

从github获取的源代码缺少configure执行文件,你需要它来生成makefiles。

苹果提供了curl源代码及其所需的MacOS / iOS构建设置,可以在他们的开源浏览器中找到:

https://opensource.apple.com/source/curl/

https://opensource.apple.com/release/macos-112.html

  1. 下载并解压源代码

  2. 设置环境变量 - 苹果平台(macOS,iOS,tvOS,watchOS及其模拟器对应项)

    export ARCH=arm64

    export SDK=iphoneos

    export DEPLOYMENT_TARGET=11.0

    export CFLAGS="-arch $ARCH -isysroot $(xcrun -sdk $SDK --show-sdk-path) -m$SDK-version-min=$DEPLOYMENT_TARGET"

  3. 进入/curl目录

  4. 运行:./configure --with-darwinssl

我的使用情况是在Azure DevOps中的托管macOS构建代理上构建iOS应用程序


1

我犯了一个新手错误,把URL放在引号里面(curl -v -k "https://URL.com")。把链接放在单引号里面(curl -v -k 'https://URL.com')之后,curl就可以接受https URL。


去掉引号并将链接改为 curl https://example.com 而不是 curl "https://example.com",这样就可以了。谢谢! - Seeya

0
2023年Ventura的更新解决方案。首先,您需要使用brew安装openssl和curl:
brew install openssl
brew install curl

接下来,您需要将安装的curl版本导出到您使用的zsh或其他shell中,使用以下命令(如果在Intel上运行,请更改路径为/usr/local):

export PATH="/opt/homebrew/opt/curl/bin:$PATH"' >> ~/.zshrc

然后只需使用 curl -V 检查可用的协议,您应该会看到 https、sftp 等。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接