# ClientCertificateExpiring

The client certificate an LDAPDirectory presents to its directory expires within 30 days; the resource is still Ready=True.

## Meaning

The server presents the certificate from the kubernetes.io/tls Secret
`spec.clientCertificateRef` names in every TLS handshake with the directory, and its
`notAfter`, in `status.clientCertificateNotAfter`, is less than 30 days away. The message
gives the instant. Google Workspace's Secure LDAP issues these certificates for three years
and sends no reminder; nothing else warns before it expires.

## Impact

Nothing yet: the directory still accepts the certificate and users sign in. Once it expires
the directory refuses every connection, so no user of the organization can sign in with
their directory password, and the operator's next send is refused as `client_certificate
expired`. Plan the replacement now.

## Diagnosis

1. `kubectl -n <ns> get ldapdirectory <name> -o jsonpath='{.status.clientCertificateNotAfter}'`
   gives the expiry; `.status.clientCertificateFingerprint` names the certificate in use.
2. `kubectl -n <ns> get secret <secret> -o jsonpath='{.data.tls\.crt}' | base64 -d | openssl x509 -noout -enddate -fingerprint -sha256`
   shows what the Secret holds, without printing the key.
3. `nauthera_operator_reconciles_total{kind="LDAPDirectory",reason="ClientCertificateExpiring"}`
   counts the reconciles that found it.

## Mitigation

- Google Workspace: in the Admin console, under Apps, LDAP, open the client and generate a
  new certificate, then download it with its key.
- Another directory: issue a new certificate from the CA the directory trusts for clients.
- Write the new pair to the Secret as `tls.crt` and `tls.key`
  (`kubectl -n <ns> create secret tls <secret> --cert=<crt> --key=<key> --dry-run=client -o yaml | kubectl apply -f -`).
  The operator sends it at once; sign-ins in flight finish on the old certificate and the
  next connection presents the new one. The condition returns to Registered.

## Escalation

If the Secret holds the new pair and the condition still names the old expiry, or the
directory refuses the new certificate, open an issue with the resource's namespace and
name, the condition message, both fingerprints and the server and operator versions.
Never attach `tls.key`.

---

[Operator failure reasons](https://www.nauthera.io/docs/v1/runbooks/operator) · Generated from [`operator/internal/runbook/conditions.yaml`](https://github.com/nauthera/nauthera-server/blob/main/operator/internal/runbook/conditions.yaml) in nauthera-server.
