在尝试访问HTTPS url时,如何使用cURL处理证书?

在尝试访问HTTPS url时,如何使用cURL处理证书?,curl,https,Curl,Https,使用curl时出现以下错误: curl: (77) error setting certificate verify locations: CAfile: /etc/ssl/certs/ca-certificates.crt CApath: none curl:(77)设置证书验证位置时出错: CAfile:/etc/ssl/certs/ca-certificates.crt 卡帕斯:没有 如何设置此证书验证位置?谢谢 您的curl似乎指向一个不存在的具有CA证书或类似证书的文件 有关使

使用curl时出现以下错误:

curl: (77) error setting certificate verify locations: CAfile: /etc/ssl/certs/ca-certificates.crt CApath: none curl:(77)设置证书验证位置时出错: CAfile:/etc/ssl/certs/ca-certificates.crt 卡帕斯:没有
如何设置此证书验证位置?谢谢

您的curl似乎指向一个不存在的具有CA证书或类似证书的文件


有关使用curl的CA证书的主要参考,请参阅:

您的curl似乎指向一个不存在的使用CA证书或类似证书的文件


有关使用curl的CA证书的主要参考,请参阅:

From
$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.
——证书类型
(SSL)告诉curl提供的证书的证书类型
他在。PEM、DER和ENG是公认的类型。如果没有规定,
假定为PEM。
如果多次使用此选项,将使用最后一个选项。
--卡塞特
(SSL)告诉curl使用指定的证书文件进行验证
同伴。该文件可能包含多个CA证书。这个
证书必须采用PEM格式。通常,卷曲是为了
为此使用默认文件,因此此选项通常用于
更改默认文件。

来自
$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.
——证书类型
(SSL)告诉curl提供的证书的证书类型
他在。PEM、DER和ENG是公认的类型。如果没有规定,
假定为PEM。
如果多次使用此选项,将使用最后一个选项。
--卡塞特
(SSL)告诉curl使用指定的证书文件进行验证
同伴。该文件可能包含多个CA证书。这个
证书必须采用PEM格式。通常,卷曲是为了
为此使用默认文件,因此此选项通常用于
更改默认文件。

此错误与缺少的包有关:
ca证书
。安装它

在Ubuntu Linux(和类似的发行版)中:

在CygWin via

在ArchLinux中(Raspberry Pi)


文件说明:

此软件包包括CA证书的PEM文件,以允许基于SSL的应用程序检查SSL连接的真实性


如所示:

此错误与缺少的包有关:
ca证书
。安装它

在Ubuntu Linux(和类似的发行版)中:

在CygWin via

在ArchLinux中(Raspberry Pi)


文件说明:

此软件包包括CA证书的PEM文件,以允许基于SSL的应用程序检查SSL连接的真实性


如:

解决此错误的最快方法是在curl请求中的某个位置添加-k选项。该选项“允许在没有证书的情况下连接到SSL cites”

请注意,这可能意味着您没有与您认为自己是的端点交谈,因为他们正在提供一个未经您信任的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
我添加了on-k:

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

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

绕过此错误的最快方法是在curl请求中的某个位置添加-k选项。该选项“允许在没有证书的情况下连接到SSL cites”

请注意,这可能意味着您没有与您认为自己是的端点交谈,因为他们正在提供一个未经您信任的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
我添加了on-k:

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

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

curl默认情况下使用“bundle”执行
SSL
证书验证 属于
证书颁发机构(CA)
公钥(CA证书)。默认值 bundle名为curl-ca-bundle.crt;您可以指定备用文件 使用--cacert选项

如果此
HTTPS
服务器使用由中表示的CA签名的证书 对于捆绑包,证书验证可能由于错误而失败 证书有问题(可能已过期,或者名称可能已过期) 与URL中的域名不匹配)

如果要关闭curl对证书的验证,请使用 -k(或
--unsecure
)选项

比如说

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

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

如果此
HTTPS
服务器使用由中表示的CA签名的证书 对于捆绑包,证书验证可能由于错误而失败 证书有问题(可能已过期,或者名称可能已过期) 与URL中的域名不匹配)

如果要关闭curl对证书的验证,请使用 -k(或
--unsecure
)选项

比如说

curl --insecure http://........
这对我有用

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文件夹:使用chmod 777-R folderNAME创建一个并更改权限这对我来说很有效

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文件夹:使用chmod 777-R folderNAME创建一个并更改权限我也安装了最新版本的ca证书,但仍然收到错误:

curl: (77) error setting certificate verify locations:
  CAfile: /etc/pki/tls/certs/ca-bundle.crt
  CApath: none
问题是curl希望证书位于路径
/etc/pki/tls/certs/ca bundle.crt
,但找不到它,因为它位于路径
/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
为我工作。如果需要,您需要为目标目标创建文件夹
-----BEGIN CERTIFICATE-----
MIIEDTCCAvWgAwIBAgIJAN..lots of certificate text....AwIBAgIJAN-----END CERTIFICATE-----
curl --version
# curl 7.51.0 (x86_64-alpine-linux-musl) libcurl/7.51.0 OpenSSL/1.0.2j zlib/1.2.8 libssh2/1.7.0
# Protocols: dict file ftp ftps gopher http https imap imaps pop3 pop3s rtsp scp sftp smb smbs smtp smtps telnet tftp 
# Features: IPv6 Largefile NTLM NTLM_WB SSL libz TLS-SRP UnixSockets 
git config --global http.sslverify "false"
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-----
...
FROM alpine
RUN apk add ca-certificates curl
COPY mycompanyRootCA.crt  /usr/local/share/ca-certificates/mycompanyRootCA.crt
RUN update-ca-certificates
sudo apt install ca-certificates --reinstall
/usr/ssl/certs/ca-bundle.crt
p11-kit extract --overwrite --format pem-bundle /usr/ssl/certs/ca-bundle.crt