请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

x509: certificate signed by unknown authority 错误

老师这个是我制作的kubeconfig文件,使用这个文件是可以登录k8s dashboard的。

root@k8s-master1:/apps/k8s_use/makeca# cat user1.kubeconfig 
apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUR1RENDQXFDZ0F3SUJBZ0lVVUh2OVZGWHFXM00xaXhzN1Vwa01janV5cmh3d0RRWUpLb1pJaHZjTkFRRUwKQlFBd1lURUxNQWtHQTFVRUJoTUNRMDR4RVRBUEJnTlZCQWdUQ0VoaGJtZGFhRzkxTVFzd0NRWURWUVFIRXdKWQpVekVNTUFvR0ExVUVDaE1EYXpoek1ROHdEUVlEVlFRTEV3WlRlWE4wWlcweEV6QVJCZ05WQkFNVENtdDFZbVZ5CmJtVjBaWE13SUJjTk1qSXdPVEF6TVRRME9EQXdXaGdQTWpFeU1qQTRNVEF4TkRRNE1EQmFNR0V4Q3pBSkJnTlYKQkFZVEFrTk9NUkV3RHdZRFZRUUlFd2hJWVc1bldtaHZkVEVMTUFrR0ExVUVCeE1DV0ZNeEREQUtCZ05WQkFvVApBMnM0Y3pFUE1BMEdBMVVFQ3hNR1UzbHpkR1Z0TVJNd0VRWURWUVFERXdwcmRXSmxjbTVsZEdWek1JSUJJakFOCkJna3Foa2lHOXcwQkFRRUZBQU9DQVE4QU1JSUJDZ0tDQVFFQXhmdFlXeERSNEVCVkFaVkZ0OW8zdEw1SE5mNFMKUDk5MndkS2xxckNGeDF4dWJyalZyYWJFOFlhZEU0RWY0bjkzV0RCQ2NWbk5mMEpaQlNWcWZGYlZSeXZ4VWRXSQpTSlJ2bnVQWnNIMmFGd2VjZ0tTZy9NcmRyNUtLbk93Mkd0b0I5cWpiYmVwcmZ1N294Y241bHV6SHdMTWdOTXlWClYyWTdESTB4WUJueHp2QkFFZTNrYjB0NW91ZXdObUdMRU1ja1VOM2ViTEhmdFN4Q1M1Zmh5aGxLV0dwWE5ocVcKNWkwZ2loQlQ2RlVBT05Ga0RUTVNOWTJETk91RnFhZDhXZjNINjBnU1l6R1NoMmNPVDJjVHA4OE8rVUpoaTUvQwpZdnVRMkhvdWxvejN6ZmswTEJWTmRCVkEvZmJEcy9sMVh1MWU5M3hJNEd6cEJjcnlUYzU0SmFYK1Z3SURBUUFCCm8yWXdaREFPQmdOVkhROEJBZjhFQkFNQ0FRWXdFZ1lEVlIwVEFRSC9CQWd3QmdFQi93SUJBakFkQmdOVkhRNEUKRmdRVW1jT09wTGFuS2ZCQ3F2OElORm9ZbnY5Rk1MY3dId1lEVlIwakJCZ3dGb0FVbWNPT3BMYW5LZkJDcXY4SQpORm9ZbnY5Rk1MY3dEUVlKS29aSWh2Y05BUUVMQlFBRGdnRUJBQldiQmxGd3hTbTVhbFY2RjJNYUhxYjhkRko5CmtINUxpUXRFZmVGemFWbHYxQWNTektObjhXT2lTdjk0Zm43eFNjdm9VT0xLQVFCaloxQlpPelR3djFnUUhqZ00KRkdKTDkrQ2MvdDBvcHVQZk5Sd2tCY3Jhek5kNWx2UnRqeURCNXY1WnhTRFdWZHhNalZTWUx6cERpVys0U2k5NgpuU0I0M2NxMURMc21KQlR4SDRPQU5SUGhZRS80RmdRbUhoZmVVb3hzRGFFMW9KMUVHeEh4OXV4WXRYcjlpQ2VtCklwdGZoVytNZXp4RER0RGppaSt4WEhDT01Zc05QMjdpODZ1TUFTL3VvaVFvN2dMOFZmVkQyVU5vZTF4STZXRDQKZGJLSXZaVjUvUWVGLzdYN0p0RHdhMFQ3TERJN0pBdDQ1N1MvdWtHR3lhSHdvd1liMjl4Q3hWdWEzOEE9Ci0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K
    server: https://192.168.2.50:6443
  name: cluster1
contexts:
- context:
    cluster: cluster1
    namespace: test
    user: user1
  name: cluster1
current-context: cluster1
kind: Config
preferences: {}
users:
- name: user1
  user:
    client-certificate-data: LS0tLS1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NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJ0ZXN0Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZWNyZXQubmFtZSI6InVzZXIxLXRva2VuLXpwYm5sIiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQubmFtZSI6InVzZXIxIiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQudWlkIjoiZmVjMTJlNjEtYjg4My00YTZmLTliY2ItZTg3YjJlMDAyM2Q3Iiwic3ViIjoic3lzdGVtOnNlcnZpY2VhY2NvdW50OnRlc3Q6dXNlcjEifQ.kbWaayKarMwspTBKyW1wYME-S-knHsenGM0TghUA90Ns4D2o8yKZT0hBMsZo33hl_RcM9kVuieL-Sqr2GDTmKID-HKGhKDwO17hCrvGTFJxAPzQBuEgwUQgrPeSqR9zLcdH7qryZ80usc4RQgydOq3Z5si9EtAJSPsp63vVEjDl-qTXQDyNLN3XakEN4LmppJiLC71BtzXwL6_V6pnPAN_NFZgGu99GhHjmtNymzj1_Zze5pyzOX0wa45dqePITZ3Uq-F2udUHd4lTz1A5Pwi05tMrlc0kRMCmVP-JaFkv2VNIqrEbaUlMNUp1Z1OsMWJSuKDJc5pJqyVX02Anudxg

在K8SWithToken函数中,在不使用ca的时候。BrareaToken使用上面的token的时候,连接k8s会报错:
x509: certificate signed by unknown authority
这个报错和你那个报错 not trusted是不一样的。

还有一个问题:那个CA文件我应该用哪个?使用 user1.kubeconfig文件中certificate-authority-data字段的内容吗?

正在回答 回答被采纳积分+3

1回答

暮闲 2023-08-06 09:17:21

同学你好 CA证书用K8S的根证书 就是你这里的certificate-authority-data,这个字段的值和k8s master节点 /etc/kubernetes/pki/ca.crt的内容是一致的。

0 回复 有任何疑惑可以回复我~
  • 提问者 404_ #1
    我的ca用的是user1.kubeconfig文件中certificate-authority-data字段的值。
    BearerTokenFile 用的是 token 字段的值。
    但是 仍然报错 x509: certificate signed by unknown authority
    回复 有任何疑惑可以回复我~ 2023-08-06 10:16:03
  • 暮闲 回复 提问者 404_ #2
    用这个试试看呢  /etc/kubernetes/pki/ca.crt
    回复 有任何疑惑可以回复我~ 2023-08-06 12:16:07
问题已解决,确定采纳
还有疑问,暂不采纳
意见反馈 帮助中心 APP下载
官方微信