Ein Kollege hat die keycloak.conf „aufgeräumt“ und Keycloak neu gestartet. Seitdem bekommt der Pod mit seinem ServiceAccount-Token keinen Keycloak-Token mehr. Am Client hat sich nichts geändert, am Cluster auch nicht – der Fehler steht nur im Journal von Keycloak.
Symptom
kubectl exec -n laden kasse -- curl -s $URL --data-urlencode grant_type=client_credentials --data-urlencode client_assertion_type=$TYP --data-urlencode client_assertion@/var/run/secrets/empfang/token
{"error":"invalid_client","error_description":"Invalid client or Invalid client credentials"}
Die Antwort an den Client verrät absichtlich wenig.
Diagnose
Ins Journal von Keycloak, nach Warnungen allgemein. Danach die Konfiguration ansehen.
sudo journalctl -u keycloak --no-pager -o cat --since "-5min" --grep "Failed to load|CLIENT_LOGIN_ERROR" WARN [org.keycloak.broker.kubernetes.KubernetesIdentityProvider] (executor-thread-1) Failed to load public keys for Kubernetes IdP 'cluster' with issuer 'https://172.16.0.126:6443': java.lang.RuntimeException: Error when loading public keys: javax.net.ssl.SSLHandshakeException: (certificate_unknown) PKIX path building failed: … unable to find valid certification path to requested target cat /opt/keycloak/conf/keycloak.conf # Ausweisstelle des Bürogebäudes – Laborbetrieb (start-dev) http-host=0.0.0.0 http-port=8080 hostname=http://172.16.0.126:8080
Ursachen
truststore-pathsDie Cluster-CA fehlt im Truststore
PKIX path building failed heißt: Java kennt die CA nicht, die das Zertifikat des API-Servers ausgestellt hat. Keycloak kann das JWKS nicht abholen und lehnt deshalb jeden Ausweis ab.
Neustartkeycloak.conf wirkt erst beim Start
Keycloak liest die keycloak.conf nur beim Start. Bis zum Neustart lief es also mit der alten Konfiguration weiter.
kidGeladene Schlüssel bleiben im Speicher
Laut Quelltext (KubernetesIdentityProvider) lädt Keycloak das JWKS erst neu, wenn ein Ausweis mit unbekannter kid kommt. Wechselt der Cluster seinen Signaturschlüssel, kann die Föderation deshalb ausfallen, obwohl niemand Keycloak angefasst hat – im Kurs nicht nachgestellt.
Lösung
sudo nano /opt/keycloak/conf/keycloak.conf truststore-paths=/opt/keycloak/conf/cluster-ca.crt sudo journalctl -u keycloak --no-pager -o cat --since "-1min" --grep "truststore" 2026-12-01 10:47:02,556 INFO [org.keycloak.truststore.TruststoreBuilder] (main) Found the following truststore files in the truststore paths [/opt/keycloak/conf/cluster-ca.crt]
Nicht tun: Auf dem Client suchen. invalid_client sagt absichtlich nichts über die Ursache – der Grund steht nur im Journal von Keycloak.
Identität für Workloads und KI-Agenten zum Anfassen, Tag 4: Föderation – Keycloak nimmt ServiceAccount-Tokens des Clusters als Ausweis an.
Zu Tag 4 →
Häufige Fragen
Was macht truststore-paths in Keycloak?
Die Option nennt zusätzliche Zertifikate, denen Keycloak bei ausgehenden HTTPS-Verbindungen vertraut – hier die CA des Kubernetes-API-Servers.
Warum funktionierte es bis zum Neustart?
Keycloak liest die keycloak.conf nur beim Start und hält einmal geladene Schlüssel im Speicher.