podcertcontroller: derive the test clock from the CA it verifies against - #1151
Open
NekoPunch (orangeCatDeveloper) wants to merge 1 commit into
Open
Conversation
…s against testNow was sampled at package init, before the CA existed. x509 stores whole seconds, so a second boundary between the two samples rounded the CA's NotBefore past testNow and the leaf failed to verify.
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.
Fixes #1150
TestMakeCertfails intermittently because verification runs one second before the generated CA becomes valid, causing the leaf's certificate chain to be rejected.testNowwas sampled at package initialization, before the CA existed, while the CA'sNotBeforewas sampled later byGenerateED25519CA. x509 encodes times at whole-second precision, so if a second boundary fell between those samples, the CA's encodedNotBeforewas one second later thantestNowand verification ran before the CA was valid.The test clock now comes from the CA the test just built, so the two instants can no longer be ordered by chance. The four call sites each use their own CA, keeping the fix local to the tests and avoiding a production change.
NotBeforeis parsed back from DER and is already whole-second, so nothing has to truncate.Deriving it also separates the injected clock from wall time by a minute, which is what a fixed clock is for: with the old
testNowa signer that reached fortime.Now()instead of the injected clock produced almost the same timestamps and went unnoticed.Independent processes, since
testNowwas a package-level variable and only a fresh process resampled it:Positive control — forcing the clock one second behind reproduces CI's message verbatim:
Mutation check, replacing
h.clock.Now()in the signer with a wall-clock read: