Repository navigation
🤖 fix: date the serving CA's NotAfter from the injected clock - #232
Conversation
Change-Id: I6aad3fc4239fbd66ab767ed1312325280f4af555 Signed-off-by: Thomas Kosiewski <tk@coder.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@codex review |
|
@codex security review |
|
Codex Review: Didn't find any major issues. Keep them coming! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
🛡️ Codex Security ReviewSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
Summary
The serving CA's
NotAfternow comes from the injected clock, like itsNotBeforesince #223.Generate(namespace, now)builds the CA template itself instead of callingcertutil.NewSelfSignedCACert, so both ends of the CA's validity derive fromnow.Fixes #224
Background
certutil.NewSelfSignedCACerttakesNotAfterfrom its owntime.Now()+ 10 years (vendor/k8s.io/client-go/util/cert/cert.go:61,79), andcertutil.Confighas no field to override it. The serving certificate is clamped to the CA'sNotAfter. Today this only moves a 10-year boundary, but it makes long-horizon tests and clock-skewed replicas harder to reason about.Implementation
CAValidity = 10 * 365 * 24h: the same 10 years that certutil uses.Generatecreates the self-signed CA withx509.CreateCertificate. Every field is the same as certutil's: subject CN and organization,DNSNames: [CN], key usages, basic constraints,IsCA.NotBefore = now - 1h(unchanged from 🤖 fix: date the serving CA from the injected clock and backdate it #223), andNotAfter = now + CAValidity.randomSerial()helper now generates the serial for both the CA and the serving certificate (same algorithm as before: uniform in[1, MaxInt64)).TestGenerateDatesCAValidityWindowFromFarPastClockusesnow = 2001-02-03T04:05:06Z. It asserts the CA'sNotBeforeandNotAfterand the servingNotAfterexactly, thatParseandNeedsRenewalaccept the bundle atnow, and thatParseat the wall clock reports an expired CA.Validation
main(CA NotAfter = 2036-10-10 ..., want 2011-02-01 04:05:06) and passes with the fix.Generateand one withcertutil.NewSelfSignedCACertfrom the same key andNotBefore. After the raw bytes, signature, serial andNotAfterwere cleared, the two parsedx509.Certificatevalues werereflect.DeepEqual. So the extensions, the subject key ID and the key usages did not change.make verify-vendor,make test,make test-integration,make build,make lint,GOFLAGS=-mod=vendor go tool govulncheck ./..., andgo test -raceoninternal/aggregated/servingcertandinternal/app/apiserverapp.Risks
Low. Only newly generated CAs change, and only by the time between
nowand certutil's wall clock (normally zero). Existing Secrets are parsed as before. The docs statement "The CA is valid for 10 years" stays true.Generated with
mux• Model:anthropic:claude-opus-5-5• Thinking:high