安装Brew失败:curl(77)错误设置证书验证。

16

好的,所以我正在使用一个老旧的Mac 10.6.8和Homebrew。Brew Doctor没有报告任何错误,我已经尝试了Brew Prune Update等操作。每次我尝试安装一个软件包时,都会出现以下错误:

curl: (77) error setting certificate verify locations:
CAfile: /etc/ssl/certs/ca-certificates.crt
CApath: /usr/local/etc/openssl/certs

我已经尝试了所有的方法,openssl已经安装好了,但是提到的文件夹找不到。
/usr/local/etc/openssl/certs

以及
/etc/ssl/certs/ca-certificates.crt

这里没有。有人能救我吗?

完整示例:

jonathan-fullers-iMac% brew install git 
Updating Homebrew...
==> Installing dependencies for git: xz
==> Installing git dependency: xz
==> Downloading https://downloads.sourceforge.net/project/lzmautils/xz-5.2.3.tar

curl: (77) error setting certificate verify locations:
CAfile: /etc/ssl/certs/ca-certificates.crt
CApath: /usr/local/etc/openssl/certs
Trying a mirror...
==> Downloading https://tukaani.org/xz/xz-5.2.3.tar.gz

curl: (77) error setting certificate verify locations:
CAfile: /etc/ssl/certs/ca-certificates.crt
CApath: /usr/local/etc/openssl/certs
Error: Failed to download resource "xz"
Download failed: https://tukaani.org/xz/xz-5.2.3.tar.gz

brew doctor 报告如下:

jonathan-fullers-iMac% brew doctor
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry and just ignore them. Thanks!

Warning: You are using macOS 10.6.
We (and Apple) do not provide support for this old version.
You may encounter build failures or other breakages.
Please create pull-requests instead of filing issues.

编辑

发现了一个无用的 .curlrc 文件,已删除,现在错误信息变为:

jonathan-fullers-iMac% curl https://github.com
curl: (77) error setting certificate verify locations:
CAfile: /usr/local/etc/openssl/cert.pem
CApath: /usr/local/etc/openssl/certs

但是 PEM 文件在那里...

jonathan-fullers-iMac% pwd && echo "\r\n" && ls
/usr/local/etc/openssl
cert.pem    certs       misc        openssl.cnf private

这是我的路径,以防万一:

jonathan-fullers-iMac% echo $PATH
/Users/werlious/.bin:
/usr/local/bin:
/usr/local/opt/curl/bin:
/usr/bin:
/bin:
/usr/sbin:
/sbin:
/usr/local/bin:
/usr/X11/bin

另一个编辑 我尝试重新安装openssl,安装没有出现错误,但卸载时出现了问题:

jonathan-fullers-iMac% brew uninstall --ignore-dependencies openssl && brew install openssl
Uninstalling /usr/local/Cellar/openssl/1.0.2l... (1,701 files, 12.7MB)
dyld: Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
  Referenced from: /usr/local/opt/curl/bin/curl
  Reason: image not found
dyld: Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
  Referenced from: /usr/local/opt/curl/bin/curl
  Reason: image not found
dyld: Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
  Referenced from: /usr/local/opt/curl/bin/curl
  Reason: image not found
dyld: Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
  Referenced from: /usr/local/opt/curl/bin/curl
  Reason: image not found
dyld: Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
  Referenced from: /usr/local/opt/curl/bin/curl
  Reason: image not found
dyld: Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
  Referenced from: /usr/local/opt/curl/bin/curl
  Reason: image not found
Updating Homebrew...
dyld: Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
  Referenced from: /usr/local/opt/curl/bin/curl
  Reason: image not found
dyld: Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
  Referenced from: /usr/local/opt/curl/bin/curl
  Reason: image not found

又一次更新 所以在重新安装了openssl之后,现在我有了这个:

jonathan-fullers-iMac% brew install python
Updating Homebrew...
==> Installing dependencies for python: readline, sqlite, gdbm
==> Installing python dependency: readline
==> Downloading https://ftp.gnu.org/gnu/readline/readline-7.0.tar.gz
  curl: (77) error setting certificate verify locations:
   CAfile: /usr/local/etc/openssl/cert.pem
   CApath: /usr/local/etc/openssl/certs
Trying a mirror... 
==> Downloading https://ftpmirror.gnu.org/readline/readline-7.0.tar.gz
==> Downloading from http://mirrors.ibiblio.org/gnu/ftp/gnu/readline/readline-7.
######################################################################## 100.0%
==> Downloading https://ftp.gnu.org/gnu/readline/readline-7.0-patches/readline70

curl: (77) error setting certificate verify locations:
  CAfile: /usr/local/etc/openssl/cert.pem
  CApath: /usr/local/etc/openssl/certs
Trying a mirror...
==> Downloading https://ftpmirror.gnu.org/readline/readline-7.0-patches/readline
==> Downloading from http://mirror.easthsia.com/gnu/readline/readline-7.0-patche
######################################################################## 100.0%
==> Downloading https://ftp.gnu.org/gnu/readline/readline-7.0-patches/readline70

curl: (77) error setting certificate verify locations:
  CAfile: /usr/local/etc/openssl/cert.pem
  CApath: /usr/local/etc/openssl/certs
Trying a mirror... 
==> Downloading https://ftpmirror.gnu.org/readline/readline-7.0-patches/readline
==> Downloading from http://mirrors.ibiblio.org/gnu/ftp/gnu/readline/readline-7.
######################################################################## 100.0%
==> Downloading https://ftp.gnu.org/gnu/readline/readline-7.0-patches/readline70

curl: (77) error setting certificate verify locations:
  CAfile: /usr/local/etc/openssl/cert.pem
  CApath: /usr/local/etc/openssl/certs
Trying a mirror...
==> Downloading https://ftpmirror.gnu.org/readline/readline-7.0-patches/readline
==> Downloading from http://mirror.us-midwest-1.nexcess.net/gnu/readline/readlin
 ######################################################################## 100.0%
 ==> Patching
==> Applying readline70-001
patching file history.c
patching file patchlevel  
==> Applying readline70-002
patching file history.c
patching file patchlevel
==> Applying readline70-003
patching file input.c
patching file patchlevel
==> ./configure --prefix=/usr/local/Cellar/readline/7.0.3_1
==> make install
==> Caveats
This formula is keg-only, which means it was not symlinked into /usr/local,
because macOS provides the BSD libedit library, which shadows libreadline.
In order to prevent conflicts when programs look for libreadline we are
defaulting this GNU Readline installation to keg-only..
For compilers to find this software you may need to set:
   LDFLAGS:  -L/usr/local/opt/readline/lib
   CPPFLAGS: -I/usr/local/opt/readline/include

==> Summary
/usr/local/Cellar/readline/7.0.3_1: 46 files, 1.5MB, built in 3 minutes 6 seconds
==> Installing python dependency: sqlite
==> Downloading https://sqlite.org/2017/sqlite-autoconf-3200000.tar.gz

curl: (77) error setting certificate verify locations:
  CAfile: /usr/local/etc/openssl/cert.pem
  CApath: /usr/local/etc/openssl/certs
Error: Failed to download resource "sqlite"
Download failed: https://sqlite.org/2017/sqlite-autoconf-3200000.tar.gz

我很困惑,对于接下来的情况毫无头绪。

这段内容与IT技术相关性不大,是否需要翻译其他内容呢?

如果有跟我一样的问题,需要一个简单的解决方案,你可以下载 .tar.xz 包并将其放置在 ~/Library/caches/Homebrew 目录下。 - Stone Info Labs
Homebrew不支持macOS 10.6。考虑使用Tigerbrew代替。 - bfontaine
5个回答

27
该错误消息表明curl无法使用openssl建立安全连接。您可以:
首先,确保您的系统上已经安装了openssl库。
echo insecure >> ~/.curlrc
git config --global http.sslVerify false

然后重新安装openssl和curl

HOMEBREW_CURLRC=1 brew reinstall openssl curl

最后

sed -i '/^insecure$/d' ~/.curlrc
git config --global http.sslVerify true

2
这对我有用。虽然我不需要更改git配置,但只更改curl配置文件就足够了。谢谢! - Tom Saenen

3

我在这里找到了解决方案

打开钥匙串访问,在 /usr/local/etc/openssl 目录下导出所有系统根证书。


2

Stone Info Labs的解决方案效果很好——

想要更加清晰明了——

/usr/local/etc/openssl中应该已经有一个cert.pem文件,可能是一个空文件。当您从钥匙串导出系统根证书时,Certificates.pem需要重命名为cert.pem,否则您可以将原始证书代码复制并粘贴到该文件中。

这样你就可以愉快地使用brew啦。


0

我尝试运行brew tap aws/tap时遇到了相同的错误:error setting certificate verify locations: CAfile: /etc/ssl/cert.pem CApath: none

我试过用git config --global http.sslverify false,但还是没有解决。然后我运行了git config --list,发现有两个配置,原因很奇怪 -
http.sslverify=false
http.sslverify=true 我移除了第二个,问题就解决了。 希望这能帮助到别人,祝好运。


0

我对这个问题感到非常生气。我的解决方法如下:

brew install openssl@3
mkdir -p  /usr/local/etc/openssl/certs/
ln -s /usr/local/etc/openssl@3/cert.pem /usr/local/etc/openssl/certs/cert.pem 
rbenv install 3.1.2
# success

请查看@rbenv/ruby-build,关于在Mac 12.6 (21G115)上安装Ruby 3.1.2失败的问题 #2061。


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