Skip to content
LF Cert Trainer

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

1/11View certificate details
0:00 / 3:37

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:

  1. Find the certificate file that a component really uses.
  2. Decode it, because the file is base64 text that tells you nothing as it is.
  3. 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 kubeadmBuilt by hand ("the hard way")
Control plane runs asStatic Podssystemd services on the host
Start-up flags are in/etc/kubernetes/manifests/*.yamlUnit files, for example /etc/systemd/system/kube-apiserver.service
Read the flags withcat or grep on the manifestsystemctl cat kube-apiserver
Logskubectl logs, or crictl logs when the API is downjournalctl -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-apiserverWhat the file is
--tls-cert-file, --tls-private-key-fileThe server certificate the API server shows to kubectl, kubelets and every other client
--client-ca-fileThe CA used to check client certificates of users and components
--etcd-certfile, --etcd-keyfileThe client certificate the API server shows to etcd
--etcd-cafileThe CA used to check etcd's server certificate
--kubelet-client-certificate, --kubelet-client-keyThe 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.

Where a kubeadm cluster keeps its certificatesflagssubdirholdsor pathStatic Pod manifestskubernetes/manifests/etc/kubernetes/pkiCA, apiserver, clientspki/etcdetcd CA, server, peerkubeconfig filesadmin.conf, kubelet.confClient certificateembedded, or a path/var/lib/kubelet/pkirotated by the kubelet
Where a kubeadm cluster keeps its certificates. The static Pod manifests name the files in /etc/kubernetes/pki. Kubeconfig files carry a client certificate inside them, except kubelet.conf, which points to a file the kubelet rotates by itself.

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.

Find the file, decode it, comparefindpathdecodeprintscheckManifest or unithow the process startsCertificate flag--tls-cert-file=...apiserver.crtPEM file on diskopenssl x509-text -nooutDecoded fieldsnames, issuer, datesComparewith what is required
Find the file, decode it, compare. Never guess a path. The component's own start-up flags say which file it loads; openssl turns that file into text; you compare the text with what the component needs.

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 fileIts CNSigns
pki/ca.crtkubernetesThe API server certificate and every client certificate used against the API server
pki/etcd/ca.crtetcd-caEverything that talks to etcd: its server and peer certificates and the API server's etcd client certificate
pki/front-proxy-ca.crtfront-proxy-caThe 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.

CertificateSubject CNOrganization (O)Issuer CN
ca.crtkubernetesnonekubernetes (self-signed)
apiserver.crtkube-apiservernonekubernetes
apiserver-kubelet-client.crtkube-apiserver-kubelet-clientkubeadm:cluster-adminskubernetes
apiserver-etcd-client.crtkube-apiserver-etcd-clientnoneetcd-ca
etcd/ca.crtetcd-canoneetcd-ca (self-signed)
etcd/server.crtthe node namenoneetcd-ca
etcd/peer.crtthe node namenoneetcd-ca
etcd/healthcheck-client.crtkube-etcd-healthcheck-clientnoneetcd-ca
front-proxy-ca.crtfront-proxy-canonefront-proxy-ca (self-signed)
front-proxy-client.crtfront-proxy-clientnonefront-proxy-ca

The client certificates inside the kubeconfig files in /etc/kubernetes are all signed by kubernetes:

KubeconfigSubject CNOrganization (O)
admin.confkubernetes-adminkubeadm:cluster-admins
super-admin.confkubernetes-super-adminsystem:masters
controller-manager.confsystem:kube-controller-managernone
scheduler.confsystem:kube-schedulernone
kubelet.confsystem:node: followed by the node namesystem: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.conf contains 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 as node01-ca@1764502463, not kubernetes. 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:

From the log message to the field to readreadthenreadthenreadthenhas expiredor is not yet validValidityNot Before, Not AfterRenew itkubeadm certs renewunknown authoritysigned by ...Issueragainst the CA fileFix the CA pathor sign with the right CAvalid for A, not Bname mismatchSubject Alt NameDNS names and IPsReissue itwith the missing name
From the log message to the field to read. Go's TLS library reports three different x509 failures. Each one tells you which part of the certificate to look at first.

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 logField to readUsual cause
x509: certificate has expired or is not yet valid: current time ... is after ...ValidityThe certificate ran out, or the node's clock is wrong
x509: certificate signed by unknown authorityIssuer, and the CA file of the side that complainsA 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 CSubject Alternative NameThe client used an address that is not in the SAN list
open /etc/kubernetes/pki/....crt: no such file or directoryThe flag itselfA typo in the path, or the file is not mounted into the Pod
tls: private key does not match public keyThe certificate and key pairThe .crt and .key flags point to files from two different pairs
remote error: tls: bad certificate or tls: unknown certificate authorityThe other side's logsThe 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.crt and apiserver-kubelet-client.crt look alike in a listing. Take the path from the flag that matters for the connection that fails.
  • Running openssl x509 on a key or a kubeconfig. A .key file and a .conf file are not certificates, and openssl answers Could not read certificate. Decode client-certificate-data with base64 -d first.
  • 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 in pki/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-expiration lists all expiry dates on a control plane node: one year for certificates, ten for CAs. The kubelet's certificates in /var/lib/kubelet/pki are separate.
  • A kubeconfig holds its certificate as base64: base64 -d, then openssl.
  • When kubectl is dead, use crictl ps -a and crictl logs, or journalctl -u for 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.