curl: (60) Peer‘s Certificate issuer is not recognized.

1 篇文章 0 订阅
本文档描述了在Linux环境中遇到HTTPS证书未被认可的问题,并提供了详细的解决方案。首先,通过`openssl`命令将`.cer`证书转换为`.pem`格式,然后将其追加到系统的信任证书列表 `/etc/pki/tls/certs/ca-bundle.crt`。完成这些步骤后,重新尝试访问,证书验证错误得到解决,但可能会出现401 Unauthorized错误,这通常意味着权限问题。
摘要由CSDN通过智能技术生成
1.linux 访问 https 证书问题

[root@kube-node2 ~]# curl https://192.168.0.200:8443
curl: (60) Peer's Certificate issuer is not recognized.
More details here: http://curl.haxx.se/docs/sslcerts.html

curl performs SSL certificate verification by default, using a "bundle"
 of Certificate Authority (CA) public keys (CA certs). If the default
 bundle file isn't adequate, you can specify an alternate file
 using the --cacert option.
If this HTTPS server uses a certificate signed by a CA represented in
 the bundle, the certificate verification probably failed due to a
 problem with the certificate (it might be expired, or the name might
 not match the domain name in the URL).
If you'd like to turn off curl's verification of the certificate, use
 the -k (or --insecure) option.




2.现有 证书twca.cer 需要添加到 linux 证书信任列表

转换格式 .cer 到 .pem
openssl x509 -inform der -in twca.cer  -out twca.pem
 
#追加到信任列表
cat twca.pem >> /etc/pki/tls/certs/ca-bundle.crt

[root@kube-node2 k8s]# cd /etc/kubernetes/cert/
[root@kube-node2 cert]# ls
ca-config.json  kube-controller-manager-key.pem         kubelet-client-current.pem  kubernetes-key.pem      metrics-server.pem
ca-key.pem      kube-controller-manager.pem             kubelet.crt                 kubernetes.pem
ca.pem          kubelet-client-2018-09-11-11-01-24.pem  kubelet.key                 metrics-server-key.pem
[root@kube-node2 cert]# cat ca.pem >> /etc/pki/tls/certs/ca-bundle.crt
[root@kube-node2 cert]# cat ca-key.pem >> /etc/pki/tls/certs/ca-bundle.crt




3.添加后访问就不会出现上面错误,


[root@kube-node2 cert]# curl https://192.168.0.200:8443
{
  "kind": "Status",
  "apiVersion": "v1",
  "metadata": {
    
  },
  "status": "Failure",
  "message": "Unauthorized",
  "reason": "Unauthorized",
  "code": 401
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
这个错误提示通常表示证书的颁发机构未被信任,可能是因为证书是自签名的或者是从未知的颁发机构获取的。这种情况下,您可以尝试以下几种方法来解决这个问题: 1. 忽略证书错误:如果您确定目标网站的证书是可信的,您可以在使用命令时添加 --no-check-certificate 参数来忽略证书错误。例如: ``` wget --no-check-certificate https://example.com ``` 或者在使用 curl 命令时添加 -k 参数: ``` curl -k https://example.com ``` 这种方法不太安全,因为它会使您的连接变得容易受到攻击。因此,我们建议您仅在必要时使用此方法。 2. 添加证书:如果您有目标网站的证书,可以将其添加到您的系统证书库中。具体步骤可能会因操作系统而异,但通常可以使用以下命令来完成: ``` sudo cp example.crt /usr/local/share/ca-certificates/ sudo update-ca-certificates ``` 这将把证书复制到 /usr/local/share/ca-certificates/ 目录下,并更新系统证书库。 3. 安装证书颁发机构:如果证书是由未知的颁发机构签署的,您可以尝试安装该颁发机构的根证书。具体步骤可能会因操作系统而异,但通常可以使用以下命令来完成: ``` sudo apt-get install ca-certificates sudo cp example.crt /usr/local/share/ca-certificates/ sudo update-ca-certificates ``` 这将安装 ca-certificates 包,并将证书复制到 /usr/local/share/ca-certificates/ 目录下,并更新系统证书库。 请注意,这些方法都只是解决证书错误的临时方法,如果您需要频繁访问目标网站,建议您与网站管理员联系,以获取正确的证书。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值