linux添加https(SSL)证书

复制代码
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
}[root@kube-node2 cert]#
复制代码

 

posted @   HkGov  阅读(4239)  评论(2编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
阅读排行:
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 零经验选手,Compose 一天开发一款小游戏!
· 一起来玩mcp_server_sqlite,让AI帮你做增删改查!!
点击右上角即可分享
微信分享提示