config: don't require CA to be configured when rotating client cert#902
Open
zakcutner wants to merge 1 commit intoprometheus:mainfrom
Open
config: don't require CA to be configured when rotating client cert#902zakcutner wants to merge 1 commit intoprometheus:mainfrom
zakcutner wants to merge 1 commit intoprometheus:mainfrom
Conversation
When `cert_file` and `key_file` are configured but `ca_file` is not, `tlsRoundTripper.RoundTrip` rebuilds the transport on every rotation of the cert or key. The rebuild path unconditionally calls `updateRootCA` with empty CA data, which always fails (`x509.CertPool.AppendCertsFromPEM` returns false on empty input), surfacing a spurious "unable to use specified CA cert: none configured" error on every subsequent request. This error is sticky: once a rotation triggers it, the `RoundTripper` never recovers without a process restart. It is easy to hit in practice with short-lived client certificates managed by tools such as cert-manager. Skip the `updateRootCA` call when no CA is configured, so rotation of `cert_file`/`key_file` works without requiring a CA. Signed-off-by: Zak Cutner <zak@cloudflare.com>
MichaHoffmann
approved these changes
Apr 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When
cert_fileandkey_fileare configured butca_fileis not,tlsRoundTripper.RoundTriprebuilds the transport on every rotation of the cert or key. The rebuild path unconditionally callsupdateRootCAwith empty CA data, which always fails (x509.CertPool.AppendCertsFromPEMreturns false on empty input), surfacing a spuriousunable to use specified CA cert: none configurederror on every subsequent request.This error is sticky: once a rotation triggers it, the
RoundTrippernever recovers without a process restart. It is easy to hit in practice with short-lived client certificates managed by tools such as cert-manager.Background
#792 landed a guard in this same code path to prevent a nil-pointer panic when
t.settings.CA == nil. It correctly stopped the crash, but it preserved the underlying logic error: the rebuild path is entered whenever the cert or key hash changes, not only when the CA changes, and it then tries to parse a CA that was never configured.This PR fixes the root cause: when no CA is configured, skip the
updateRootCAcall entirely and keep using the originally configured TLS roots (typically the system trust store). Rotation ofcert_file/key_filenow works whether or not a CA is configured.