Skip to content

Decode all CAs in the activator's routing secret - #16707

Open
cvas22 wants to merge 1 commit into
knative:mainfrom
cvas22:fix/13877-activator-decode-all-cas
Open

cvas22 wants to merge 1 commit into
knative:mainfrom
cvas22:fix/13877-activator-decode-all-cas

Conversation

@cvas22

@cvas22 cvas22 commented Oct 17, 2026 •

Copy link
Copy Markdown

Fixes #13877

Proposed Changes

  • The activator now adds every PEM-encoded CA found in ca.crt of the routing-serving-certs secret to its upstream trust pool (via x509.CertPool.AppendCertsFromPEM), instead of only the first PEM block. This allows multiple CAs to be trusted at once, e.g. during CA rotation or with a bring-your-own CA bundle.
  • Fixes a nil pointer dereference: if ca.crt contained non-PEM data, pem.Decode returned a nil block and block.Bytes panicked in the informer handler. Now a warning is logged and the CA is ignored, matching the existing handling of invalid trust-bundle ConfigMaps.
  • Adds TestReconcile cases "Multiple CAs in secret" and "Invalid CA in secret". Both fail without the fix (the first times out because only one CA ends up in the pool; the second panics at cache.go:146) and pass with it.

Tests run locally (Windows, Go 1.26): gofmt -l, go vet ./pkg/activator/certificate/, go test ./pkg/activator/certificate/ -count=1, go build ./pkg/activator/... ./cmd/activator/. Not run locally: -race, the full unit test suite, linters beyond go vet, and e2e tests; I'm relying on CI for those.

Disclosure: I prepared this change with the help of an AI coding assistant. I reviewed the diff and tests and take responsibility for them.

Release Note

The activator now trusts all CA certificates contained in the `ca.crt` field of the `routing-serving-certs` secret, not just the first one, and no longer panics if that field holds invalid data.

The activator only decoded the first PEM block of ca.crt in the
routing-serving-certs secret, so any additional CAs (e.g. during a CA
rotation or with a bring-your-own CA bundle) were silently ignored. If
the field did not contain PEM data at all, pem.Decode returned a nil
block and the activator panicked with a nil pointer dereference.

Use x509.CertPool.AppendCertsFromPEM to add every CA in the field and
log a warning when no valid certificate is found.

Fixes knative#13877

Signed-off-by: cvas22 <cvas22@gmail.com>
@knative-prow

knative-prow Bot commented Oct 17, 2026

Copy link
Copy Markdown

Welcome @cvas22! It looks like this is your first PR to knative/serving 🎉

@knative-prow knative-prow Bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Oct 17, 2026
@knative-prow

knative-prow Bot commented Oct 17, 2026

Copy link
Copy Markdown

Hi @cvas22. Thanks for your PR.

I'm waiting for a knative member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@knative-prow
knative-prow Bot requested review from dprotaso, matzew and skonto October 17, 2026 09:59
@knative-prow

knative-prow Bot commented Oct 17, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: cvas22
Once this PR has been reviewed and has the lgtm label, please assign aliok for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Decode all CAs in secret for activator

1 participant