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

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

如何设置证书验证位置?


当前回答

从$ 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.

其他回答

解决这个错误的最快方法是在curl请求中添加-k选项。该选项“允许连接到SSL引用而不需要证书”。(来自curl—help)

请注意,这可能意味着您并没有与您认为您正在与之通信的端点通信,因为它们正在提供一个没有由您信任的CA签名的证书。

例如:

$ curl -o /usr/bin/apt-cyg https://raw.github.com/cfg/apt-cyg/master/apt-cyg

给我以下错误响应:

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

我加了-k

curl -o /usr/bin/apt-cyg https://raw.github.com/cfg/apt-cyg/master/apt-cyg -k

并且没有错误消息。作为奖励,现在我已经安装了apt-cyg。和ca证书。

这对我很有效

sudo apt-get install ca-certificates

然后进入证书文件夹

sudo cd /etc/ssl/certs

然后复制ca-certificates。CRT文件进入/etc/pki/tls/certs

sudo cp ca-certificates.crt /etc/pki/tls/certs

如果没有“tls/certs”文件夹,请创建一个“tls/certs”文件夹,并使用chmod 777 -R folderNAME修改权限

我遇到了同样的问题:我正在构建一个基于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

如果有人仍然有问题,试试这个,它对我很有效。 删除/etc/ssl/certs/目录下的文件 然后重新安装ca-certificates:

sudo apt install ca-certificates --reinstall

当我尝试安装Linuxbrew时,我这样做了。