Skip to content

Encode basicConstraints critical flag and pathlen into generated CSRs - #11030

Open
cconlon wants to merge 1 commit into
wolfSSL:masterfrom
cconlon:csrExtCritical
Open

Encode basicConstraints critical flag and pathlen into generated CSRs#11030
cconlon wants to merge 1 commit into
wolfSSL:masterfrom
cconlon:csrExtCritical

Conversation

@cconlon

@cconlon cconlon commented Jul 31, 2026

Copy link
Copy Markdown
Member

Description

ReqCertFromX509() previously did not copy basicConstCrit, pathLen, or pathLenSet from the WOLFSSL_X509 into the Cert, so a basicConstraints extension added to an X509_REQ lost its critical flag and pathlen when the CSR was signed. The certificate path (CertFromX509()) already copied these fields.

openssl req -text output for a CSR with basicConstraints added as critical, CA:TRUE, pathlen:1, shows this before/after this fix:

Before:

X509v3 Basic Constraints:
    CA:TRUE

After:

X509v3 Basic Constraints: critical
    CA:TRUE, pathlen:1

Reported in wolfSSL/wolfssljni#368.

Testing

Adds unit test test_x509_ReqCertFromX509_ext_critical, which fails without this fix.

Checklist

  • added tests
  • updated/added doxygen
  • updated appropriate READMEs
  • Updated manual and documentation

@cconlon cconlon self-assigned this Jul 31, 2026
Copilot AI review requested due to automatic review settings July 31, 2026 22:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 copy basicConstCrit, pathLen, and pathLenSet from the request into the generated Cert.
  • Add a unit test that builds a CSR with basicConstraints: critical, CA:TRUE, pathlen:1 and 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.

Comment thread src/x509.c Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants