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

Ben*_*Ben 10 macos terminal ssl curl

我在Mac OS X 10.11.2上使用终端,我无法处理任何https请求.我总是得到这个错误:

curl: (1) Protocol "https" not supported or disabled in libcurl
Run Code Online (Sandbox Code Playgroud)

我试过这个,但是我得到了一个"错误的目录"错误:

./configure --with-ssl=/usr/local/ssl
Run Code Online (Sandbox Code Playgroud)

任何意见将是有益的.

编辑:

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

configure: error: OpenSSL libs and/or directories were not found where specified!
Run Code Online (Sandbox Code Playgroud)

解:

对于Mac OS X 10.6或更高版本,使用此选项启用SSL:

./configure --with-darwinssl
Run Code Online (Sandbox Code Playgroud)

Sur*_*rya 8

以下步骤有助于解决该问题:( 注意:尽管会重建libcurl)

# First simply remove curl and try reinstall with openssl:
brew rm curl && brew install curl --with-openssl # Rerun 
Run Code Online (Sandbox Code Playgroud)

如果仍无法解决,请按照以下步骤下载并重建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
Run Code Online (Sandbox Code Playgroud)


Ben*_*Ben 7

解:

对于Mac OS X 10.6或更高版本,使用此选项启用SSL:

./configure --with-darwinssl
Run Code Online (Sandbox Code Playgroud)

  • 请问在哪里安装curl? (2认同)

Bir*_*Lee 7

Homebrew团队最近删除了cURL公式的所有安装选项,这意味着您将无法执行此操作brew install curl --with-openssl。相反,请执行brew install curl-openssl。确保首先卸载旧版本brew uninstall curl

  • 仅供参考 - 在 2021 年,建议使用“brew install curl”安装 openssl curl,请参阅此线程:https://github.com/Homebrew/discussions/discussions/1268 (3认同)
  • 这是我需要的信息,它不应该位于页面底部!其他人都说使用“--with-openssl”选项,但现在已经不可能了。此外,我还必须关闭防病毒软件,因为它会阻止连接下载 cURL 软件包。 (2认同)
  • 只是要补充一点,在此之后您需要关闭终端并重新打开它。一个小时就回不来了.. (2认同)

Pun*_*rud 5

通过将标准curl替换为支持nghttp2的curl解决了这个问题(需要brew)

brew install curl --with-nghttp2
brew link curl --force
Run Code Online (Sandbox Code Playgroud)

--http2做请求时包含

例子:

curl --http2 https://www.example.com
Run Code Online (Sandbox Code Playgroud)

或者:

curl --header 'Access-Token: o.bFbpTuazstlUZXsnyTWTaJq0biZ' \
--http2 https://www.example.com/
Run Code Online (Sandbox Code Playgroud)

参考:https: //daniel.haxx.se/blog/2016/08/01/curl-and-h2-on-mac/ https://simonecarletti.com/blog/2016/01/http2-curl-macosx/