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

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

如何设置证书验证位置?


当前回答

我还安装了最新版本的ca-certificates,但仍然出现错误:

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

问题是curl希望证书位于/etc/pki/tls/certs/ca-bundle.路径下但是无法找到它,因为它位于/etc/ssl/certs/ca-certificates.crt路径下。

通过运行将我的证书复制到预期的目的地

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

为我工作。如果目标目的地不存在文件夹,则需要运行命令为其创建文件夹

sudo mkdir -p /etc/pki/tls/certs

如果需要,修改上面的命令,使目标文件名与curl期望的路径匹配,即替换/etc/pki/tls/certs/ca-bundle.在错误消息中使用“CAfile:”后面的路径。

其他回答

只需创建文件夹,这在您的系统中是缺失的..

/ etc / pki / tls证书

并使用以下命令创建文件,

Sudo apt-get install ca-certificates

然后复制并粘贴证书到目标文件夹,这是显示在您的错误..我的是“with message”错误设置证书验证位置:CAfile: /etc/pki/tls/certs/ca-bundle.请确保您将文件粘贴到错误中提到的确切位置。使用以下命令复制粘贴..

电脑:sudo cp /etc/ssl/证书/呆滞 / etc / pki / tls证书/ ca-bundle crt。

固定的。

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

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

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

我使用MobaXterm,实习生使用Cygwin,所以即使在安装ca-certificates后使用apt-cyg安装ca-certificates问题也没有解决。

我仍然得到以下错误:

curl:(77)错误设置证书验证位置:CAfile: /etc/ssl/certs/ca-certificates. confcrt CApath: none

然后我试着列出文件/etc/ssl/certs/ca-certificates。crt和我都找不到。但是我可以找到/usr/ssl/certs/ca-bundle.因此,我复制了文件/usr/ssl/certs/ca-bundle. crtCRT为/etc/ssl/certs/ca-certificates。CRT和问题得到了解决。