Repository navigation
Decode all CAs in the activator's routing secret - #16707
Conversation
|
Welcome @cvas22! It looks like this is your first PR to knative/serving 🎉 |
|
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 Regular contributors should join the org to skip this step. Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions 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. |
|
Could someone with access add /ok-to-test here, and on #16708 too? Both are small activator fixes waiting on that. thx |
|
/ok-to-test |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #16707 +/- ##
==========================================
- Coverage 80.32% 80.32% -0.01%
==========================================
Files 217 217
Lines 13701 13690 -11
==========================================
- Hits 11006 10997 -9
+ Misses 2327 2325 -2
Partials 368 368 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
One thing we need to cover is that the docs say I'm debating validating this when we update the config map |
|
I'd close and open this PR so it refreshed HEAD |
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 <[email protected]>
Signed-off-by: Srinivas Chippagiri <[email protected]>
d134f4b to
6ed5cf6
Compare
|
Good point, thx. 6ed5cf6 decodes the bundle one PEM block at a time instead of using AppendCertsFromPEM, so each invalid cert or non-certificate block gets its own warning, plus one if nothing valid is left. Added a test with a valid and a corrupt cert in the same bundle. I rebased on main rather than closing and reopening, so HEAD should be fresh now. |
Signed-off-by: Srinivas Chippagiri <[email protected]>
|
/retest |
I guess to be clear - the operator who configures a bad cert won't know that it doesn't work until something breaks. So my comment wasn't regarding the test - but the flow from setting the config map -> processing it in the activator. |
|
Ah ok, got it. The logs only help if someone goes looking. For the trust-bundle ConfigMaps I could add a validating webhook that rejects a labeled ConfigMap when any block in it doesn't parse, so the apply fails right away. The secret's ca.crt is usually written by cert-manager rather than by hand, so I'd leave that to the activator warning. Want that in this PR or as a follow-up? The istio-latest-no-mesh failure looks unrelated btw, the API server refused connections and TestBYOCertificate panicked in its cleanup. |
|
/retest |
Let's have it in this PR |
|
Sure, I'll add it here. One question before I do: the config webhook only validates ConfigMaps by fixed name, and the trust bundles are picked by the knative-ca-trust-bundle label with any name. So I'd add a small admission controller with its own ValidatingWebhookConfiguration that selects on that label and rejects a bundle that has a block that doesn't parse. Is that the shape you had in mind, or would you rather I do something lighter? |
|
Actually we should probably skip the webhook. Long term we want to migrate to ClusterTrustBundles since they are GA in v1.37. |
Signed-off-by: Srinivas Chippagiri <[email protected]>
|
Sounds good, I'll skip the webhook here. thx for the pointer on ClusterTrustBundles. |
|
/lgtm I decided to go back to |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: cvas22, dprotaso The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/retest |
|
/cherry-pick release-1.24 |
|
@dprotaso: new pull request created: #16863 DetailsIn response to this:
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. |
|
@dprotaso: new pull request created: #16864 DetailsIn response to this:
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. |
Fixes #13877
Proposed Changes
ca.crtof therouting-serving-certssecret to its upstream trust pool (viax509.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.ca.crtcontained non-PEM data,pem.Decodereturned a nil block andblock.Bytespanicked in the informer handler. Now a warning is logged and the CA is ignored, matching the existing handling of invalid trust-bundle ConfigMaps.TestReconcilecases "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 atcache.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 beyondgo 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