Lesson 75 · Section 7: Security
Lesson 75: View certificate details: reading the certificates of a running cluster
How to find every certificate a cluster uses, decode it with openssl, and judge the four things that matter: who it names, who signed it, which addresses it covers and when it expires. Includes the routine for a control plane that is down because of a certificate. · 18 min read · 4 min video
Official competencies this lesson covers
Narrated by the local narrator voice. Keys: Space plays and pauses, J and L step, C captions, F full screen.
What viewing certificate details means
The earlier lessons of this section explained what TLS certificates are, which ones a cluster needs and how they are created. This lesson is the other direction: the cluster already exists, the files are already on disk, and you have to say whether they are right.
That is a real job. Certificates are the one part of a cluster that breaks on a schedule: every certificate has an end date, and on that date a healthy cluster stops working without anybody having changed anything. It is also a common way to break a cluster by hand, because one wrong path in a manifest is enough.
Viewing certificate details is three skills:
- Find the certificate file that a component really uses.
- Decode it, because the file is base64 text that tells you nothing as it is.
- Judge it: compare what it says with what the component needs.
How it works
Step 1: find out how the cluster was built
Where the certificates are, and where the logs are, depends on how the control plane runs.
| Built with kubeadm | Built by hand ("the hard way") | |
|---|---|---|
| Control plane runs as | Static Pods | systemd services on the host |
| Start-up flags are in | /etc/kubernetes/manifests/*.yaml | Unit files, for example /etc/systemd/system/kube-apiserver.service |
| Read the flags with | cat or grep on the manifest | systemctl cat kube-apiserver |
| Logs | kubectl logs, or crictl logs when the API is down | journalctl -u kube-apiserver |
Tell them apart in one command: ls /etc/kubernetes/manifests. If the folder holds kube-apiserver.yaml,
etcd.yaml and the others, you are on a kubeadm cluster. The exam clusters are built with kubeadm.
Step 2: let the component tell you which file it uses
Do not start in the pki folder and guess from file names. A component uses exactly the files its flags name, and
a wrong flag is one of the faults you are looking for.
grep -E '\.(crt|key)' /etc/kubernetes/manifests/kube-apiserver.yaml
- --client-ca-file=/etc/kubernetes/pki/ca.crt
- --etcd-cafile=/etc/kubernetes/pki/etcd/ca.crt
- --etcd-certfile=/etc/kubernetes/pki/apiserver-etcd-client.crt
- --etcd-keyfile=/etc/kubernetes/pki/apiserver-etcd-client.key
- --kubelet-client-certificate=/etc/kubernetes/pki/apiserver-kubelet-client.crt
- --kubelet-client-key=/etc/kubernetes/pki/apiserver-kubelet-client.key
- --proxy-client-cert-file=/etc/kubernetes/pki/front-proxy-client.crt
- --proxy-client-key-file=/etc/kubernetes/pki/front-proxy-client.key
- --requestheader-client-ca-file=/etc/kubernetes/pki/front-proxy-ca.crt
- --service-account-key-file=/etc/kubernetes/pki/sa.pub
- --service-account-signing-key-file=/etc/kubernetes/pki/sa.key
- --tls-cert-file=/etc/kubernetes/pki/apiserver.crt
- --tls-private-key-file=/etc/kubernetes/pki/apiserver.key
Read the flag names as roles:
| Flag on kube-apiserver | What the file is |
|---|---|
--tls-cert-file, --tls-private-key-file | The server certificate the API server shows to kubectl, kubelets and every other client |
--client-ca-file | The CA used to check client certificates of users and components |
--etcd-certfile, --etcd-keyfile | The client certificate the API server shows to etcd |
--etcd-cafile | The CA used to check etcd's server certificate |
--kubelet-client-certificate, --kubelet-client-key | The client certificate the API server shows to kubelets (for logs, exec and metrics) |
sa.key and sa.pub are a plain key pair for signing ServiceAccount tokens. They are not certificates, so
openssl x509 cannot read them and they never expire.
Parts:
- Static Pod manifests (kubernetes/manifests)
- /etc/kubernetes/pki (CA, apiserver, clients)
- pki/etcd (etcd CA, server, peer)
- kubeconfig files (admin.conf, kubelet.conf)
- Client certificate (embedded, or a path)
- /var/lib/kubelet/pki (rotated by the kubelet)
Connections:
- Static Pod manifests to /etc/kubernetes/pki: flags
- /etc/kubernetes/pki to pki/etcd: subdir
- kubeconfig files to Client certificate: holds
- Client certificate to /var/lib/kubelet/pki: or path
The same search works for etcd (/etc/kubernetes/manifests/etcd.yaml: --cert-file, --key-file,
--trusted-ca-file, and the --peer-* set). The controller manager and the scheduler talk to the API server with
a kubeconfig, named by their --kubeconfig flag, and their client certificate is inside that file. The kubelet is
not a Pod: its kubeconfig is /etc/kubernetes/kubelet.conf and its certificates are in /var/lib/kubelet/pki.
Step 3: decode the file
A .crt file is PEM: base64 between -----BEGIN CERTIFICATE----- and -----END CERTIFICATE-----. openssl x509
decodes it. -text prints every field and -noout leaves out the base64 block itself:
openssl x509 -in /etc/kubernetes/pki/apiserver.crt -text -noout
Certificate:
Data:
Version: 3 (0x2)
Serial Number: 6149274012783154417 (0x5556a8a7b2c2f8f1)
Signature Algorithm: sha256WithRSAEncryption
Issuer: CN = kubernetes <- who signed it
Validity
Not Before: Nov 30 11:34:23 2026 GMT
Not After : Nov 30 11:34:23 2027 GMT <- when it expires
Subject: CN = kube-apiserver <- who it names
Subject Public Key Info:
Public Key Algorithm: rsaEncryption
Public-Key: (2048 bit)
X509v3 extensions:
X509v3 Key Usage: critical
Digital Signature, Key Encipherment
X509v3 Extended Key Usage:
TLS Web Server Authentication <- what it may be used for
X509v3 Basic Constraints: critical
CA:FALSE
X509v3 Subject Alternative Name: <- which addresses it covers
DNS:controlplane, DNS:kubernetes, DNS:kubernetes.default,
DNS:kubernetes.default.svc, DNS:kubernetes.default.svc.cluster.local,
IP Address:10.96.0.1, IP Address:192.168.56.10
The arrows are added here; the long hexadecimal blocks for the key and the signature are left out.
Parts:
- Manifest or unit (how the process starts)
- Certificate flag (--tls-cert-file=...)
- apiserver.crt (PEM file on disk)
- openssl x509 (-text -noout)
- Decoded fields (names, issuer, dates)
- Compare (with what is required)
Connections:
- Manifest or unit to Certificate flag: find
- Certificate flag to apiserver.crt: path
- apiserver.crt to openssl x509: decode
- openssl x509 to Decoded fields: prints
- Decoded fields to Compare: check
Step 4: judge what you read
Subject. For a client certificate the subject is an identity. Kubernetes takes the common name (CN) as
the user name and each organization (O) as a group, and RBAC then decides what that user may do. A scheduler
certificate whose CN is not exactly system:kube-scheduler is a valid certificate for a user with no permissions.
For a server certificate the CN is only a label; clients check the alternative names instead.
Issuer. The issuer must be the CA that the other side trusts. A kubeadm cluster has three CAs, and mixing them up is the classic fault:
| CA file | Its CN | Signs |
|---|---|---|
pki/ca.crt | kubernetes | The API server certificate and every client certificate used against the API server |
pki/etcd/ca.crt | etcd-ca | Everything that talks to etcd: its server and peer certificates and the API server's etcd client certificate |
pki/front-proxy-ca.crt | front-proxy-ca | The front proxy client certificate of the aggregation layer |
A CA certificate is self-signed, so its Subject and Issuer are the same, and it carries CA:TRUE.
Subject Alternative Name (SAN). A client connects to a name or an IP address and then looks for exactly that
value in the server certificate's SAN list. For the API server the list must contain every address anyone uses to
reach it: the node's host name and IP, the names kubernetes, kubernetes.default, kubernetes.default.svc and
kubernetes.default.svc.cluster.local, the first IP of the Service range (10.96.0.1 by default) and, if there is
one, the load balancer or control plane endpoint. One missing entry breaks only the clients that use that address,
which makes it confusing: Pods work, and kubectl from your laptop does not.
Validity. Not After is the expiry date, in GMT. kubeadm issues certificates for one year and CAs for ten
years. Not Before matters too: a node whose clock is behind sees a freshly issued certificate as "not yet
valid".
Extended Key Usage. TLS Web Server Authentication marks a server certificate and TLS Web Client Authentication a client certificate. etcd's server and peer certificates carry both, because etcd members act as
client and server to each other.
What a kubeadm cluster should contain
Use this as the reference when you check a cluster. Paths are relative to /etc/kubernetes/pki.
| Certificate | Subject CN | Organization (O) | Issuer CN |
|---|---|---|---|
ca.crt | kubernetes | none | kubernetes (self-signed) |
apiserver.crt | kube-apiserver | none | kubernetes |
apiserver-kubelet-client.crt | kube-apiserver-kubelet-client | kubeadm:cluster-admins | kubernetes |
apiserver-etcd-client.crt | kube-apiserver-etcd-client | none | etcd-ca |
etcd/ca.crt | etcd-ca | none | etcd-ca (self-signed) |
etcd/server.crt | the node name | none | etcd-ca |
etcd/peer.crt | the node name | none | etcd-ca |
etcd/healthcheck-client.crt | kube-etcd-healthcheck-client | none | etcd-ca |
front-proxy-ca.crt | front-proxy-ca | none | front-proxy-ca (self-signed) |
front-proxy-client.crt | front-proxy-client | none | front-proxy-ca |
The client certificates inside the kubeconfig files in /etc/kubernetes are all signed by kubernetes:
| Kubeconfig | Subject CN | Organization (O) |
|---|---|---|
admin.conf | kubernetes-admin | kubeadm:cluster-admins |
super-admin.conf | kubernetes-super-admin | system:masters |
controller-manager.conf | system:kube-controller-manager | none |
scheduler.conf | system:kube-scheduler | none |
kubelet.conf | system:node: followed by the node name | system:nodes |
Under the hood · The kubelet's certificates are a separate story
The kubelet has two certificates in /var/lib/kubelet/pki, and kubeadm manages neither of them after the node has
joined.
- Client certificate, used towards the API server:
kubelet-client-current.pem. It is a symlink to a dated file that holds the certificate and the key. The kubelet asks the cluster for a new one before the old one expires and moves the symlink, so this file renews itself.kubelet.confcontains a path to it instead of an embedded certificate. - Serving certificate, shown to the API server on port 10250:
kubelet.crt. By default the kubelet creates it itself and it is self-signed: the issuer is a name such asnode01-ca@1764502463, notkubernetes. That is normal on a kubeadm cluster and not something to repair.
Both files decode with the same command: openssl x509 -in /var/lib/kubelet/pki/kubelet-client-current.pem -noout -subject -issuer -enddate. kubeadm certs check-expiration does not list them.
When the cluster no longer answers
If the API server or etcd is down, kubectl fails with connection refused, and you have to read logs one level
lower.
On a kubeadm cluster the components are containers, so ask the container runtime:
crictl ps -a | grep -E 'kube-apiserver|etcd' # -a shows exited containers too
crictl logs <container-id> # add 2>&1 | tail to see the last lines
journalctl -u kubelet --since "10 min ago" # the kubelet is a service, not a container
On a cluster built by hand the components are services:
journalctl -u etcd.service -l
journalctl -u kube-apiserver -l
The messages come from Go's TLS library and there are only a few of them:
Parts:
- has expired (or is not yet valid)
- Validity (Not Before, Not After)
- Renew it (kubeadm certs renew)
- unknown authority (signed by ...)
- Issuer (against the CA file)
- Fix the CA path (or sign with the right CA)
- valid for A, not B (name mismatch)
- Subject Alt Name (DNS names and IPs)
- Reissue it (with the missing name)
Connections:
- has expired to Validity: read
- Validity to Renew it: then
- unknown authority to Issuer: read
- Issuer to Fix the CA path: then
- valid for A, not B to Subject Alt Name: read
- Subject Alt Name to Reissue it: then
| Message in the log | Field to read | Usual cause |
|---|---|---|
x509: certificate has expired or is not yet valid: current time ... is after ... | Validity | The certificate ran out, or the node's clock is wrong |
x509: certificate signed by unknown authority | Issuer, and the CA file of the side that complains | A flag points to the wrong CA (for example ca.crt where etcd/ca.crt is needed), or the certificate was signed by the wrong CA |
x509: certificate is valid for A, B, not C | Subject Alternative Name | The client used an address that is not in the SAN list |
open /etc/kubernetes/pki/....crt: no such file or directory | The flag itself | A typo in the path, or the file is not mounted into the Pod |
tls: private key does not match public key | The certificate and key pair | The .crt and .key flags point to files from two different pairs |
remote error: tls: bad certificate or tls: unknown certificate authority | The other side's logs | The peer rejected the certificate you presented; its log has the reason |
Using it
Example · Check the API server's certificate
The task: report the common name, the issuer, the alternative names and the expiry date of the certificate the API server presents.
Find the file, then ask only for the fields you need:
grep tls-cert-file /etc/kubernetes/manifests/kube-apiserver.yaml
openssl x509 -in /etc/kubernetes/pki/apiserver.crt -noout -subject -issuer -dates -ext subjectAltName
subject=CN = kube-apiserver
issuer=CN = kubernetes
notBefore=Nov 30 11:34:23 2026 GMT
notAfter=Nov 30 11:34:23 2027 GMT
X509v3 Subject Alternative Name:
DNS:controlplane, DNS:kubernetes, DNS:kubernetes.default, DNS:kubernetes.default.svc, DNS:kubernetes.default.svc.cluster.local, IP Address:10.96.0.1, IP Address:192.168.56.10
If you cannot remember -ext, the full dump with grep gives the same line:
openssl x509 -in /etc/kubernetes/pki/apiserver.crt -text -noout | grep -A1 "Alternative Name"
Example · List every expiry date
On a control plane node, kubeadm reads all the certificates it manages, including the ones inside the kubeconfig files:
kubeadm certs check-expiration
CERTIFICATE EXPIRES RESIDUAL TIME CERTIFICATE AUTHORITY EXTERNALLY MANAGED
admin.conf Nov 30, 2027 11:34 UTC 364d ca no
apiserver Nov 30, 2027 11:34 UTC 364d ca no
apiserver-etcd-client Nov 30, 2027 11:34 UTC 364d etcd-ca no
apiserver-kubelet-client Nov 30, 2027 11:34 UTC 364d ca no
controller-manager.conf Nov 30, 2027 11:34 UTC 364d ca no
etcd-healthcheck-client Nov 30, 2027 11:34 UTC 364d etcd-ca no
etcd-peer Nov 30, 2027 11:34 UTC 364d etcd-ca no
etcd-server Nov 30, 2027 11:34 UTC 364d etcd-ca no
front-proxy-client Nov 30, 2027 11:34 UTC 364d front-proxy-ca no
scheduler.conf Nov 30, 2027 11:34 UTC 364d ca no
super-admin.conf Nov 30, 2027 11:34 UTC 364d ca no
CERTIFICATE AUTHORITY EXPIRES RESIDUAL TIME EXTERNALLY MANAGED
ca Nov 27, 2036 11:34 UTC 9y no
etcd-ca Nov 27, 2036 11:34 UTC 9y no
front-proxy-ca Nov 27, 2036 11:34 UTC 9y no
The command reads files on the node where you run it, so repeat it on every control plane node. On a cluster without kubeadm, or when you want the kubelet's files too, loop over the folders:
for c in /etc/kubernetes/pki/*.crt /etc/kubernetes/pki/etcd/*.crt /var/lib/kubelet/pki/kubelet.crt; do
echo "$(openssl x509 -in "$c" -noout -enddate) $c"
done
kubeadm renews its certificates during every kubeadm upgrade, so a cluster that is upgraded at least once a year
never reaches the dates in this list. A cluster that is left alone does.
Example · Read the certificate inside a kubeconfig
A kubeconfig stores its client certificate as base64 in client-certificate-data. Decode it and pipe it to
openssl, which reads standard input when there is no -in:
kubectl config view --raw -o jsonpath='{.users[0].user.client-certificate-data}' \
| base64 -d | openssl x509 -noout -subject -issuer -enddate
subject=O = kubeadm:cluster-admins, CN = kubernetes-admin
issuer=CN = kubernetes
notAfter=Nov 30 11:34:23 2027 GMT
For a file other than your current kubeconfig, without kubectl:
grep client-certificate-data /etc/kubernetes/scheduler.conf | awk '{print $2}' \
| base64 -d | openssl x509 -noout -subject -enddate
subject=CN = system:kube-scheduler
notAfter=Nov 30 11:34:23 2027 GMT
This is how you answer "which user and groups does this kubeconfig log in as?" without asking the API server.
Example · Repair an API server that cannot reach etcd
kubectl answers connection refused. Look at the containers:
crictl ps -a | grep -E 'kube-apiserver|etcd'
3f1c0a9d2b7e4 2 minutes ago Running etcd 0 8a1f6c3d9e2b4
9b2e7c4f1a6d0 20 seconds ago Exited kube-apiserver 6 51c2a7e8f0d31
etcd runs; the API server keeps exiting. Read its last lines:
crictl logs 9b2e7c4f1a6d0 2>&1 | tail -n 3
W1130 10:12:44.108155 1 logging.go:55] [core] [Channel #1 SubChannel #2] grpc: addrConn.createTransport failed
to connect to {Addr: "127.0.0.1:2379"}. Err: connection error: desc = "transport: authentication handshake failed:
tls: failed to verify certificate: x509: certificate signed by unknown authority"
Port 2379 is etcd, and "unknown authority" points to the issuer. Compare the CA that the API server uses for etcd with the issuer of etcd's server certificate:
grep etcd-cafile /etc/kubernetes/manifests/kube-apiserver.yaml
# - --etcd-cafile=/etc/kubernetes/pki/ca.crt <- the cluster CA
openssl x509 -in /etc/kubernetes/pki/etcd/server.crt -noout -issuer
# issuer=CN = etcd-ca <- signed by the etcd CA
The flag names the wrong CA. Edit the manifest so that it reads --etcd-cafile=/etc/kubernetes/pki/etcd/ca.crt,
save, and wait: the kubelet notices the changed file and starts a new API server container within a minute.
watch crictl ps # kube-apiserver appears and stays Running
kubectl get nodes
Example · See the certificate a running server presents
The file on disk and the certificate in use can differ, because a process loads its certificate when it starts. After a renewal, check what the live server shows:
openssl s_client -connect 192.168.56.10:6443 </dev/null 2>/dev/null \
| openssl x509 -noout -subject -enddate
subject=CN = kube-apiserver
notAfter=Nov 30 11:34:23 2027 GMT
If this date is older than the one in apiserver.crt, the API server has not been restarted since the renewal.
Tricks
Common mistakes
- Reading the wrong file.
apiserver.crt,apiserver-etcd-client.crtandapiserver-kubelet-client.crtlook alike in a listing. Take the path from the flag that matters for the connection that fails. - Running
openssl x509on a key or a kubeconfig. A.keyfile and a.conffile are not certificates, and openssl answersCould not read certificate. Decodeclient-certificate-datawithbase64 -dfirst. - Forgetting
-noout. Without it the base64 block is printed after the fields you asked for. - Looking for the address in the CN. Clients compare the address they dial with the SAN list only. A correct CN with a missing SAN still fails.
- Treating the etcd CA and the cluster CA as one. Both files are called
ca.crt. The one inpki/etcd/is a different CA, and every etcd flag needs that one. - Calling the kubelet's self-signed serving certificate a fault. On a default kubeadm cluster it is expected.
- Assuming the control plane picks up a changed file. After a renewal the static Pods must be restarted before the new certificate is in use.
- Misreading the time zone. openssl prints GMT; compare with
date -u, not with your local clock.
Recap
- Find the file first: the flags in
/etc/kubernetes/manifests/*.yaml(kubeadm) or in the systemd unit (built by hand) name every certificate a component uses. - Decode it with
openssl x509 -in FILE -text -noout, or ask for single fields with-subject -issuer -dates -ext subjectAltName. - Judge four things: Subject (user and groups for client certificates), Issuer (one of three CAs), Subject Alternative Name (every address clients use) and Not After.
kubeadm certs check-expirationlists all expiry dates on a control plane node: one year for certificates, ten for CAs. The kubelet's certificates in/var/lib/kubelet/pkiare separate.- A kubeconfig holds its certificate as base64:
base64 -d, then openssl. - When
kubectlis dead, usecrictl ps -aandcrictl logs, orjournalctl -ufor services, and map the x509 message to a field: expired means Validity, unknown authority means Issuer, "valid for A, not B" means SAN.
Official docs
Quiz: check what you learned
5 questions on this lesson · about 3 min · instant feedback. Missed questions come back in your review queue.
Sign in to take the quiz and keep your score.
Practise: try it on a real cluster
2 hands-on labs for this lesson. You get goals, not steps: any solution that reaches them passes.
Use kubeadm on a running cluster: read the configuration it was built with, print a join command that works, and renew the API server's certificate and prove that the new one is served.
Build · Level 2 · standard · target 20 min
Decode the certificates stored in a namespace with openssl and find the one that expired, the one about to expire, the one from the wrong CA and the one whose key does not fit.
Investigate · Level 2 · standard · target 20 min
Discussion
Learners ask and answer questions here. Sign in to read and join the discussion.