skip to content
Alvin Lucillo

Get raw cert from kubeconfig

/ 1 min read

To get raw certificate from a kubeconfig under a specific user, use jsonpath (as specified below) and pass --raw so that the certificate value is printed in base64 format. Now that you have the base64 value, you can decode it with base64 -d.

k --kubeconfig /opt/kubeconfig config view --raw -ojsonpath="{.users[0].user.client-certificate-data}" | base64 -d

-----BEGIN CERTIFICATE-----
MIICvDCCAaQCFHYdjSZFKCyUCR1B2naXCg/UjSHLMA0GCSqGSIb3DQEBCwUAMBUx
[redacted]
-----END CERTIFICATE-----