我得到以下错误使用卷曲:
curl: (77) error setting certificate verify locations: CAfile: /etc/ssl/certs/ca-certificates.crt CApath: none
如何设置证书验证位置?
我得到以下错误使用卷曲:
curl: (77) error setting certificate verify locations: CAfile: /etc/ssl/certs/ca-certificates.crt CApath: none
如何设置证书验证位置?
当前回答
此错误与缺少一个包有关:ca-certificates。安装它。
在Ubuntu Linux(以及类似的发行版)中:
# apt-get install ca-certificates
通过Apt-Cyg在CygWin中
# apt-cyg install ca-certificates
在Arch Linux下(树莓派)
# pacman -S ca-certificates
文档告诉我们:
该包包含CA证书的PEM文件,允许基于SSL的应用程序检查SSL连接的真实性。
在Debian——压缩包ca-certificates的详细信息
其他回答
我在Ubuntu 20.04 localhost上试图访问运行在docker容器中的elasticsearch时遇到了这个curl 77问题。集装箱启动后:
Check curl without ssl: curl --cacert http_ca.crt -u elastic https://localhost:9200 -k lowercase -k for insecure connection. Check curl configs: curl-config --configure, noticed what is ca-bundle: --with-ca-bundle=/etc/ssl/certs/ca-certificates.crt. Copy http_ca.crt file from container to:/usr/local/share/ca-certificates/, original command is here. Run update on ca-certificates: sudo update-ca-certificates. Run curl: curl -u elastic:<password> https://localhost:9201. Finally got response with "tagline" : "You Know, for Search".
将<password>修改为运行Docker Image时生成的密码。 还要注意,在我的机器上,弹性是在端口9201上启动的(不知道为什么:sudo ss -tlpn | grep 9200给我什么都没有),我已经找到了端口:sudo netstat -ntlp和程序名称是docker-proxy。
我遇到了同样的问题:我正在构建一个基于alpine的docker映像,当我想要卷曲到我的组织的网站时,出现了这个错误。为了解决这个问题,我必须获得我公司的CA证书,然后,我必须把它添加到我的图像的CA证书中。
获取CA证书
使用OpenSSL获取网站相关证书:
openssl s_client -showcerts -servername my.company.website.org -connect my.company.website.org:443
这将输出如下内容:
CONNECTED(00000005)
depth=2 CN = UbisoftRootCA
verify error:num=19:self signed certificate in certificate chain
...
-----BEGIN CERTIFICATE-----
...
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
...
-----END CERTIFICATE-----
...
获取最后一个证书(-----BEGIN certificate -----和 -----END CERTIFICATE----- markups包括),并将其保存到一个文件(mycompanyRootCA。例如CRT)
建立你的形象
然后,当您从alpine构建docker映像时,执行以下操作:
FROM alpine
RUN apk add ca-certificates curl
COPY mycompanyRootCA.crt /usr/local/share/ca-certificates/mycompanyRootCA.crt
RUN update-ca-certificates
您的映像现在将正常工作!\ o /
似乎您的卷曲指向一个不存在的文件与CA证书或类似。
有关CA certs与curl的主要参考,请参见:https://curl.haxx.se/docs/sslcerts.html
在git bash中运行以下命令,这对我来说很好
git config --global http.sslverify "false"
从$ man curl:
--cert-type <type>
(SSL) Tells curl what certificate type the provided certificate
is in. PEM, DER and ENG are recognized types. If not specified,
PEM is assumed.
If this option is used several times, the last one will be used.
--cacert <CA certificate>
(SSL) Tells curl to use the specified certificate file to verify
the peer. The file may contain multiple CA certificates. The
certificate(s) must be in PEM format. Normally curl is built to
use a default file for this, so this option is typically used to
alter that default file.