Skip to content

CSR/CA/X509 refactor and extension support - #285

Open
aidankeefe2022 wants to merge 5 commits into
wolfSSL:mainfrom
aidankeefe2022:csr-ca-x509-only
Open

aidankeefe2022 wants to merge 5 commits into
wolfSSL:mainfrom
aidankeefe2022:csr-ca-x509-only

Conversation

@aidankeefe2022

Copy link
Copy Markdown
Member

Rework the req, x509 and ca commands and their extension handling, and extend the x509 request test suite to cover them.

  • req: rework option parsing and the CSR/self-sign/CA-sign paths, add -serial and -CAkey
  • config: parse subjectAltName, authorityKeyIdentifier, subjectKeyIdentifier, keyUsage, extendedKeyUsage and basicConstraints, from both -addext and config sections

-addext remains single-use, as on main.

fixed issues from skoll review

scope reduction

@aidankeefe2022
aidankeefe2022 force-pushed the csr-ca-x509-only branch 3 times, most recently from 466704f to 0106d36 Compare August 25, 2026 15:04
@aidankeefe2022 aidankeefe2022 self-assigned this Aug 25, 2026
@aidankeefe2022
aidankeefe2022 marked this pull request as ready for review August 25, 2026 16:49

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Fenrir Automated Review — PR #285

Scan targets checked: wolfclu-bugs, wolfclu-src

Findings: 2
2 finding(s) posted as inline comments (see file-level comments below)

This review was generated automatically by Fenrir. Reported findings require changes before merge.

Comment thread src/x509/clu_request_setup.c Resolved
Comment thread src/x509/clu_config.c Resolved
Comment thread src/x509/clu_request_setup.c Resolved
Comment thread src/x509/clu_config.c Resolved
@aidankeefe2022

Copy link
Copy Markdown
Member Author

retest this please

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Fenrir Automated Review — PR #285

Scan targets checked: wolfclu-bugs, wolfclu-src

Fenrir result: Approved ✅

No new issues found in the changed files.

Advisory only — this automated result does not count as a GitHub approval.

@wolfSSL-Fenrir-bot
wolfSSL-Fenrir-bot dismissed their stale review August 27, 2026 18:02

Fenrir's latest completed scan found no issues; clearing the prior automated change request.

Rework the req, x509 and ca commands and their extension handling, and
extend the x509 request test suite to cover them.

  - req: rework option parsing and the CSR/self-sign/CA-sign paths, add
    -serial and -CAkey
  - config: parse subjectAltName, authorityKeyIdentifier,
    subjectKeyIdentifier, keyUsage, extendedKeyUsage and
    basicConstraints, from both -addext and config sections

wolfCLU_GetOpt is rewritten as a left-to-right argv walk rather than a
scan of the option table, which the reworked x509 parsing depends on.
That is cross-cutting, so the commands taking positional arguments
(enc, dsaparam, dhparam, genkey, rand, sign/verify) are adapted to it
and wolfCLU_checkForArg now takes a struct option. Commands that only
take flags are untouched.

-addext remains single-use, as on main.

fixed issues from skoll review

scope reduction
Copilot AI balanced review requested due to automatic review settings November 9, 2026 18:28
@aidankeefe2022

Copy link
Copy Markdown
Member Author

rebase

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.

🟡 Changes recommended

Unresolved defects can bypass CA constraint overrides in NO_SHA builds and cause private-key loss when output paths refer to the same file.

4 open issues
What changed in this PR

Refactors wolfCLU’s certificate request and issuance workflows and expands extension handling across req, x509, and ca.

Changes:

  • Separates CSR creation, self-signing, and CA-signing paths, with stricter option validation and explicit extension-copying controls.
  • Expands extension parsing and updates certificate validity, serial generation, and issuer key-identifier handling.
  • Adds regression tests and updates command documentation.
File Description
wolfclu/​x509/​clu_x509_sign.h Exposes the shared certificate validity helper.
wolfclu/​x509/​clu_cert.h Defines validity limits and random serial width.
wolfclu/​clu_optargs.h Adds option identifiers for issuance controls.
wolfclu/​clu_header_main.h Adds issuer context to extension handling.
tests/​x509/​x509-req-test.py Expands signing, extension, and option regression coverage.
tests/​x509/​x509-ca-test.py Tests CA validity bounds.
src/​x509/​clu_x509_sign.c Shares validity handling and passes issuer context.
src/​x509/​clu_request_setup.c Refactors request parsing, signing, verification, and output.
src/​x509/​clu_config.c Expands extension parsing and validation.
src/​x509/​clu_cert_setup.c Adds bounded validity options and mutation checks.
src/​x509/​clu_ca_setup.c Tightens option handling and failure cleanup.
src/​clu_main.c Adds a comment explaining exit-status normalization.
manpages/​wolfssl-x509.1 Documents validity and extension option restrictions.
manpages/​wolfssl-req.1 Documents CA issuance and revised request options.
manpages/​wolfssl-ca.1 Documents validity bounds.

Review effort: Balanced

!wolfSSL_X509_ext_isSet_by_NID(x509, NID_basic_constraints)) {
WOLFSSL_X509_EXTENSION *newExt;
WOLFSSL_ASN1_OBJECT *obj;
#if defined(WOLFSSL_CERT_EXT) && !defined(NO_SHA)
Comment on lines +2119 to +2120
if (outKeyBio != NULL &&
XSTRCMP(outKeyFile, outFile) == 0) {
Comment thread src/x509/clu_cert_setup.c
* certificate is only written out when -req makes it re-signed. Checked
* once for both so the two options do not disagree: without this,
* -extfile exited 0 having quietly dropped every extension asked for. */
if (ret == WOLFCLU_SUCCESS && !reqFlag && (extFile != NULL || days > 0)) {
Comment on lines +1583 to +1590
case WOLFCLU_CAFILE:
caFile = optarg;
break;

case WOLFCLU_CAKEY:
caKeyFile = optarg;
break;

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.

4 participants