首页 > 解决方案 > Curl 无法处理网站给出 ssl 错误

问题描述

尝试使用自制软件安装某些东西时,我遇到了来自 curl 和证书问题的大量消息。

以为cert.pem文件有问题,但实际上并没有。

brew install ffmpeg下载了很多包,很顺利,然后需要glib的包:

curl https://download.gnome.org/sources/glib/2.66/glib-2.66.1.tar.xz  
curl: (77) SSL: can't load CA certificate file cacert.pem

如果错误是由于环境变量问题引起的,我尝试了:

curl --cacert ./cacert.pem https://download.gnome.org/sources/glib/2.66/glib-2.66.1.tar.xz  
curl: (35) SSL peer handshake failed, the server most likely requires a client certificate to connect

我想验证 wget 是否有同样的问题。但是 wget 似乎能够在 gnome.org 上“失败”,并为 rpmfind.net 自动更改

wget https://download.gnome.org/sources/glib/2.66/glib-2.66.1.tar.xz
https://download.gnome.org/sources/glib/2.66/glib-2.66.1.tar.xz
Résolution de download.gnome.org (download.gnome.org)… 8.43.85.29, 8.43.85.13, 8.43.85.14, ...
Connexion à download.gnome.org (download.gnome.org) 8.43.85.29 :443… connecté.
requête HTTP transmise, en attente de la réponse… 302 
Found Emplacement : http://ftp.rpmfind.net/linux/gnome.org/sources/glib/2.66/glib-2.66.1.tar.xz 
 suivant
http://ftp.rpmfind.net/linux/gnome.org/sources/glib/2.66/glib-2.66.1.tar.xz
Résolution de ftp.rpmfind.net (ftp.rpmfind.net)… 195.220.108.108
Connexion à ftp.rpmfind.net (ftp.rpmfind.net) 195.220.108.108 :80… connecté.
requête HTTP transmise, en attente de la réponse… 200 OK
Taille : 4834784 (4,6M) application/x-xz
Sauvegarde en: glib-2.66.1.tar.xz

然后我用 curl 和 rpmfind.net 进行了检查,一切顺利:

curl --cacert ./cacert.pem https://fr2.rpmfind.net/linux/gnome.org/sources/glib/2.66/glib-2.66.1.tar.xz

Safari 浏览器也无法访问https://download.gnome.org/sources/
因此,无法按照某些帖子中的建议进行操作:在 MacOSX 钥匙串中添加 gnome.org 证书。
为什么 curl 提示 SSL/CA 证书错误?
我看到了很多关于 homebrew、curl 和证书的线程,但似乎没有一个与这个案例有关。并且 homebrew 能够安装其他软件包,当它们不在 gnome.org 上时。
自制软件中有没有办法使用 wget 而不是 curl?
是否可以修改自制软件的配方,以便它可以在其他地方获得包装?
感谢您提供任何线索。

标签: sslcurlcertificatehomebrewwget

解决方案


感谢这篇文章:
如何手动下载 brew 包进行安装?

我能够将下载的 glib 包从 rpmfind 移动到自制软件缓存结构的正确位置和名称。

brew --cache glib给出缓存的 glib 包的正确自制程序名称。
mv glib-2.66.1.tar.xz [homebrew name]
brew install glib现在可以了,因为丢失的包位于托管目录中。


推荐阅读