Improve validity encoding for certificates - #49
Merged
lealem47 merged 1 commit intoJul 23, 2026
Conversation
sebastian-carpenter
requested review from
Copilot and
lealem47
and removed request for
Copilot
July 22, 2026 21:19
There was a problem hiding this comment.
Pull request overview
This PR updates certificate generation validity handling in wolfx509 to stop relying on wolfCrypt’s daysValid-based API and instead encode NotBefore/NotAfter explicitly in the Go wrapper, supporting exact-date validity windows and a ValidDays convenience mode.
Changes:
- Introduces
Certificate.ValidDaysand aresolveValidity()helper to derive(NotBefore, NotAfter)from supported input combinations. - Encodes ASN.1 UTCTime vs GeneralizedTime in Go (
encodeValidityTime) and writes the encoded values into the wolfCryptCertstruct fields. - Updates and expands tests to validate validity resolution and ASN.1 encoding, including GeneralizedTime coverage.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| wolfx509/README.md | Documents supported validity input modes and the one-day backdate behavior. |
| wolfx509/certificate.go | Adds ValidDays to the Certificate template. |
| wolfx509/certgen.go | Switches to resolved (NotBefore, NotAfter) and adds ASN.1 time encoding helpers. |
| wolfx509/certgen_wolfcrypt.go | Writes encoded validity times into wolfCrypt cert buffers instead of using daysValid. |
| wolfx509/certgen_test.go | Updates existing vectors and adds broader tests for validity resolution and encoding. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
sebastian-carpenter
force-pushed
the
rounded-cert-validity
branch
from
July 22, 2026 21:40
5bcbd9f to
b85f543
Compare
lealem47
approved these changes
Jul 23, 2026
lealem47
left a comment
Contributor
There was a problem hiding this comment.
Thanks @sebastian-carpenter !
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 F-5327
The validity encoding part of cert generation previously relied on the validDays API from wolfcrypt, updated the code to use exact dates for encoding. ASN.1 encoding for the times is now done in the GO wrapper because of this but the result should be more robust.
Inputs styles for generating certificates (also defined in wolfx509/README.md):
NotBeforeandNotAfter- the literal validityNotAfteralone -NotBeforeis set to now then backdated one day to match wolfcrypt.ValidDaysalone -NotBeforecalculated as above.NotAfterwill beValidDaysafter now.Intentionally left out the
NotBefore+ValidDayscombination. But it could be added later if desired.I had to change the test vectors but this should maintain backwards compatibility. Otherwise, a lot of vectors were added to confirm correctness.