Encode basicConstraints critical flag and pathlen into generated CSRs - #11030
Open
cconlon wants to merge 1 commit into
Open
Encode basicConstraints critical flag and pathlen into generated CSRs#11030cconlon wants to merge 1 commit into
cconlon wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes CSR generation so a basicConstraints extension added to an X509_REQ preserves its critical flag and pathLen when the CSR is signed, aligning request behavior with the existing certificate path (CertFromX509()).
Changes:
- Update
ReqCertFromX509()to copybasicConstCrit,pathLen, andpathLenSetfrom the request into the generatedCert. - Add a unit test that builds a CSR with
basicConstraints: critical, CA:TRUE, pathlen:1and verifies these fields round-trip through DER parsing. - Register the new unit test in the X.509 API test declarations.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| tests/api/test_x509.h | Registers the new CSR basicConstraints critical/pathLen unit test. |
| tests/api/test_x509.c | Adds test_x509_ReqCertFromX509_ext_critical() to validate DER encoding round-trip for critical + pathLen. |
| src/x509.c | Copies basicConstraints critical/pathLen fields from request into Cert during CSR signing. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
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.
Description
ReqCertFromX509()previously did not copybasicConstCrit,pathLen, orpathLenSetfrom theWOLFSSL_X509into theCert, so a basicConstraints extension added to anX509_REQlost its critical flag and pathlen when the CSR was signed. The certificate path (CertFromX509()) already copied these fields.openssl req -textoutput for a CSR with basicConstraints added as critical, CA:TRUE, pathlen:1, shows this before/after this fix:Before:
After:
Reported in wolfSSL/wolfssljni#368.
Testing
Adds unit test
test_x509_ReqCertFromX509_ext_critical, which fails without this fix.Checklist