Skip to content

Operator webhook: "x509: certificate signed by unknown authority"

Python & Gotested on Go 1.26, Kubebuilder v4, controller-runtime, envtest

The certificate was renewed, the caBundle in the webhook configuration was not. From now on the API server rejects every call to the validating webhook.

Symptom

kubectl label site demo lab/test=2 --overwrite
Error from server (InternalError): Internal error occurred: failed calling webhook
  "vstaticsite-v1alpha1.kb.io": failed to call webhook: Post "https://127.0.0.1:9443/
  validate-web-lab-example-v1alpha1-staticsite?timeout=10s": tls: failed to verify
  certificate: x509: certificate signed by unknown authority

The caBundle was replaced with a foreign CA – as after a certificate renewal that was not propagated.

Diagnosis

Whom does the API server trust, and who issued the server certificate?

grep 'TLS handshake error' run.log | tail -1
kubectl get $VWC -o jsonpath='{.webhooks[0].clientConfig.caBundle}' \
  | base64 -d | openssl x509 -noout -subject
openssl s_client -connect 127.0.0.1:9443 </dev/null 2>/dev/null \
  | openssl x509 -noout -issuer
2026/10/10 11:45:38 http: TLS handshake error from 127.0.0.1:54206: remote error:
  tls: bad certificate
subject=CN=falsche-ca
issuer=CN=127.0.0.1

Causes

caBundleWrong CA in the webhook configuration

caBundle (falsche-ca, "wrong CA") does not match the issuer of the server certificate (CN=127.0.0.1).

validation onlyOther webhooks keep working

The mutating webhook and conversion have their own caBundles and keep working – only validation no longer trusts the server.

Fix

Replace the caBundle with the CA that issued the server certificate.
kubectl label site demo lab/test=3 --overwrite
staticsite.web.lab.example/demo labeled

Don't: Setting failurePolicy to Ignore so the errors disappear – then the webhook checks nothing at all.

▶
Break it yourself and find it – free
Kubernetes operators hands-on, Day 15: a competition with eight typical operator faults, from hot loop to orphans.
Go to day 15 →

FAQ

How do I prevent this in production?

With cert-manager's CA injector: it writes the CA into caBundle automatically on every renewal.

What does tls: bad certificate in the operator log mean?

The API server aborted the handshake because it does not trust the presented certificate – the other side of the x509 error.

Related error patterns

More