Repository navigation
Description
Pre-submission checklist
- I have searched existing issues and confirmed this is not a duplicate.
Description
I suspect that when api.oidc.dex.enabled=true and api.oidc.dex.tls.selfSignedCert=true, kargo-api reverse-proxies /dex/* to the internal kargo-dex-server service over TLS, trusting Dex's certificate via the ca.crt key of the same cert-manager-issued Secret (api.oidc.dex.tls.secretName). When cert-manager renews/reissues that Certificate, kargo-api keeps failing TLS verification against Dex's newly served certificate until kargo-api is manually restarted. kargo-dex-server does not need a restart its side is fine, the certificate presented is current and valid
Steps to Reproduce
Install the chart with api.oidc.enabled=true, api.oidc.dex.enabled=true, api.oidc.dex.tls.selfSignedCert=true
Wait for (or force) cert-manager to reissue the kargo-dex-server Certificate.
Without restarting kargo-api, attempt OIDC login through the UI
Requests to /dex/.well-known/openid-configuration (and other /dex/* paths proxied by kargo-api) return an empty 502 response
UI display
OIDC: "response" is not a conformant Authorization Server Metadata response (unexpected HTTP status code)
Expected Behavior
Login continues to work across certificate renewals, either because kargo-api reloads its trusted CA at runtime, or because the deployment automatically rolls when the Dex TLS secret changes.
Actual Behavior
kargo-api fails to establish a trusted TLS connection to the internal kargo-dex-server after cert-manager renews the Dex TLS certificate, and stays broken until kargo-api is manually restarted.
Kargo Version
v1.9.5
Relevant Logs
Dex:
time=2026-08-24T00:37:58.199Z level=INFO msg="keys rotated" next_rotation=2026-08-24T06:37:58.199Z
2026/08/24 02:57:04 http: TLS handshake error from x:51240: remote error: tls: bad certificate
2026/08/24 02:57:35 http: TLS handshake error from x:49438: remote error: tls: bad certificate
time=2026-08-24T06:37:58.723Z level=INFO msg="keys expired, rotating"
time=2026-08-24T06:37:58.941Z level=INFO msg="keys rotated" next_rotation=2026-08-24T12:37:58.941Z
2026/08/24 07:22:57 http: TLS handshake error from x:59866: remote error: tls: bad certificate
2026/08/24 07:23:22 http: TLS handshake error from x:42200: remote error: tls: bad certificateScreenshots
No response
Activity
fuskovic commentedon Aug 24, 2026
Two possible approaches for reloading at runtime:
fsnotify+ poll hybrid. This is what controller-runtime's own certwatcher does for this kind of problem. Event-driven reload for low latency with a poll ticker running . They both run the whole time and either can trigger a reload. The reason the ticker is needed at all is because K8s updates a mountedSecretvia an atomic symlink swap, not an in-place write.fsnotifyswatch on the file can get invalidated by that swap and the library's own recovery (re-Add-on-Remove/Chmod) can itself fail (with no retry) if the timing is unlucky.Poll-only. A ticker re-reads the CA file every
Nseconds and atomically swaps in a fresh cert. We could optionally makeNconfigurable with something likeDEX_CA_CERT_RELOAD_INTERVALSuggestion
1 has lower latency and higher complexity. The latter is the inverse. So I think if we made the latency configurable via
DEX_CA_CERT_RELOAD_INTERVALthen I think 2 seems like a reasonable choice.Thoughts @krancour
fuskovic commentedon Aug 24, 2026
It looks like there's a second location OIDC login can break on cert rotation: https://github.com/akuity/kargo/blob/main/pkg/server/auth_middleware.go#L507-L572
getKeySetbuilds anhttpClientwhose CA trust for Dex's TLS cert is loaded once viaos.ReadFileand baked into a staticRootCAsfield (L554-L565). That client is wrapped in anoidc.RemoteKeySetand cached intoauthMiddleware.oidcTokenVerifyFnon first success, never rebuilt for the process's lifetime (L375-L379).RemoteKeySetperiodically re-fetches Dex's JWKS over that same stale trust. When cert-manager rotates Dex's TLS cert, the next JWKS refresh fails TLS verification. Breaking OIDC token verification for all users (not just new logins), silently, untilkargo-apiis restarted.We could fix by not letting
getKeySet'shttpClientfreeze aRootCAssnapshot at construction time. Instead, we give itsTransportaDialTLSContextthat re-reads a shared, live-reloadingCACertPoolon every dial so each JWKS refresh re-checks current trust instead of a cached one.krancour commentedon Aug 24, 2026
Issue acknowledged, but I would consider this a lower priority.
github-actions commentedon Nov 23, 2026
This issue has been automatically marked as stale because it had no activity for 90 days. It will be closed if no activity occurs in the next 30 days but can be reopened if it becomes relevant again.