Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

Unable to connect to the server: x509: certificate is valid for control-plane, not my_domain.com

Ask Question

I am trying to give user access to Kubernetes using X.509 Client Certificate

I am using(subjectAltName= my_domain.com):

openssl req -new -newkey rsa:4096 -nodes -keyout Bob.key -out Bob.csr -subj "/C=DK/ST=Frb/L=Cph/O=engineering/CN=Bob" -addext "subjectAltName = DNS:my_domain.com"

kube/config:

apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: <..Q0FURS0tLS0tCk..>
    server: https://my_domain.com:<port>
  name: bob
contexts:
- context:
    cluster: bob
    user: Bob
  name: bob
current-context: bob
kind: Config
preferences: {}
users:
- name: Bob
  user:
    client-certificate: /home/cred/Bob.crt
    client-key: /home/cred/Bob.key

Error:

Unable to connect to the server: x509: certificate is valid for control-plane,... not my_domain.com

Do you know how to make this work behind domain, where the local k8s server ip address is mapped?

Alright, can you confirm what exactly worked for you? so as to add as community answer for the help of other community members facing same problem. – Anant Swaraj Oct 1, 2021 at 7:07

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.