我得到以下错误使用卷曲:

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

如何设置证书验证位置?


当前回答

创建一个文件~/。使用以下内容进行Curlrc

cacert=/etc/ssl/certs/ca-certificates.crt

如下

echo "cacert=/etc/ssl/certs/ca-certificates.crt" >> ~/.curlrc

其他回答

curl默认使用“bundle”执行SSL证书验证 的证书颁发机构公钥(CA certs)。默认的 Bundle名为curl-ca-bundle.crt;您可以指定一个备用文件 使用——cacert选项。

如果此HTTPS服务器使用由中表示的CA签名的证书 ,证书验证可能失败,由于 证书的问题(它可能过期了,或者名称可能过期了 不匹配URL中的域名)。

如果您想关闭curl对证书的验证,请使用 -k(或——insecure)选项。

例如

curl --insecure http://........

我在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。

视窗:-

证书从https://curl.se/docs/caextract.html下载 重命名cacert。Pem到curl-ca-bundle.crt 将文件添加到以下任何位置

查看详情https://curl.se/docs/sslcerts.html

此错误与缺少一个包有关: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的详细信息

我也有这个问题。我的问题是这个文件:

/usr/ssl/certs/ca-bundle.crt

默认情况下只是一个空文件。因此,即使它存在,您仍然会得到错误,因为它不包含任何证书。你可以像这样生成它们:

p11-kit extract --overwrite --format pem-bundle /usr/ssl/certs/ca-bundle.crt

https://github.com/msys2/MSYS2-packages/blob/master/ca-certificates/ca-certificates.install