Skip to content

Generic X.509 certificate helpers and secure file utilities - #276

Open
stenslae wants to merge 4 commits into
wolfSSL:mainfrom
stenslae:pr-x509-only
Open

Generic X.509 certificate helpers and secure file utilities#276
stenslae wants to merge 4 commits into
wolfSSL:mainfrom
stenslae:pr-x509-only

Conversation

@stenslae

@stenslae stenslae commented Jul 15, 2026

Copy link
Copy Markdown
Member

Added helper functions to do secure file operations. Added simplified certificate parsing and mapping logic into helper functions. Existing modules were refactored to utilize new functions. Added CI tests for all new changes.

This allows for potential reduction in openssl compat layer reliance and new signature algos.

@stenslae stenslae self-assigned this Jul 15, 2026
@stenslae
stenslae requested review from wolfSSL-Fenrir-bot and removed request for wolfSSL-Fenrir-bot July 16, 2026 17:14

@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 #276

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. Findings are non-blocking.

Comment thread tests/x509/cert_setup_unit_test.c
Comment thread src/tools/clu_funcs.c
Comment thread tests/x509/cert_setup_unit_test.c
Comment thread src/tools/clu_funcs.c

@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 #276

Scan targets checked: wolfclu-bugs, wolfclu-src

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

This review was generated automatically by Fenrir. Findings are non-blocking.

Comment thread tests/x509/cert_setup_unit_test.c
Comment thread src/genkey/clu_genkey.c Outdated
Comment thread tests/x509/cert_setup_unit_test.c
Comment thread tests/x509/cert_setup_unit_test.c
Comment thread src/genkey/clu_genkey.c Outdated
Comment thread tests/x509/cert_setup_unit_test.c

@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 #276

Scan targets checked: wolfclu-bugs, wolfclu-src

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

This review was generated automatically by Fenrir. Findings are non-blocking.

Comment thread src/genkey/clu_genkey.c Outdated
Comment thread src/genkey/clu_genkey.c Outdated

@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 #276

⚠️ An internal error occurred during the automated review. This error has been logged. Please contact the Fenrir team if you need assistance.

Error: GitHubAPIError

@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 #276

⚠️ An internal error occurred during the automated review. This error has been logged. Please contact the Fenrir team if you need assistance.

Error: GitHubAPIError

@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 #276

⚠️ An internal error occurred during the automated review. This error has been logged. Please contact the Fenrir team if you need assistance.

Error: GitHubAPIError

@philljj

philljj commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

PR is failing CI.

Comment thread src/x509/clu_cert_setup.c Outdated

@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 #276

Scan targets checked: wolfclu-bugs, wolfclu-src

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

This review was generated automatically by Fenrir. Findings are non-blocking.

Comment thread src/sign-verify/clu_dgst_setup.c Outdated
Comment thread src/sign-verify/clu_dgst_setup.c Outdated

@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 #276

Scan targets checked: wolfclu-bugs, wolfclu-src

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

This review was generated automatically by Fenrir. Findings are non-blocking.

Comment thread src/x509/clu_cert_setup.c Outdated
Comment thread src/x509/clu_cert_setup.c Outdated

@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 #276

Scan targets checked: wolfclu-src
Failed targets: wolfclu-bugs

⚠️ Review incomplete — one or more scan targets failed before findings could be produced. See the Fenrir PR review detail page for logs.

@stenslae
stenslae force-pushed the pr-x509-only branch 2 times, most recently from a09fd6d to 0592d3a Compare July 29, 2026 22:06

@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 #276

Scan targets checked: wolfclu-bugs, wolfclu-src

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

This review was generated automatically by Fenrir. Findings are non-blocking.

Comment thread src/x509/clu_request_setup.c
Comment thread src/x509/clu_request_setup.c

@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 #276

Scan targets checked: wolfclu-bugs, wolfclu-src

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

This review was generated automatically by Fenrir. Findings are non-blocking.

Comment thread src/x509/clu_x509_sign.c Outdated
Comment thread src/x509/clu_x509_sign.c Outdated

@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 #276

Scan targets checked: wolfclu-bugs, wolfclu-src

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

This review was generated automatically by Fenrir. Findings are non-blocking.

Comment thread src/ecparam/clu_ecparam.c
if (in == NULL) {
wolfCLU_LogError("Error opening file %s", optarg);
ret = USER_INPUT_ERROR;
return USER_INPUT_ERROR;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 [Low] Early return on -in failure leaks -name buffer · Resource leaks on error paths

The WOLFCLU_INFILE handler now does return USER_INPUT_ERROR; directly instead of setting ret and breaking. If -name was parsed earlier in the same invocation (allocating name via XMALLOC), this bypasses the if (name != NULL) XFREE(name, ...) cleanup at the end of the function.

Fix: Set ret = USER_INPUT_ERROR; break; instead of returning directly, so the loop exits normally and reaches the existing name/bioOut/key cleanup.

Comment thread src/x509/clu_ca_setup.c
@@ -344,6 +360,9 @@ int wolfCLU_CASetup(int argc, char** argv)
if ((selfSigned || altSign) && ca != NULL) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 [Low] x509 leaked when -selfsign used without -keyfile/-cert/-altkey/-altpub · Resource leaks on error paths

wolfCLU_CertSignSetCA (which transfers x509 ownership to signer when selfSigned) only runs inside the pkey != NULL || ca != NULL || altKey != NULL || altKeyPub != NULL guard. If none are set, ownership is never transferred, but cleanup unconditionally skips wolfSSL_X509_free(x509) whenever selfSigned is true, leaking x509.

Fix: Track whether wolfCLU_CertSignSetCA actually took ownership of x509 (e.g. a boolean) and only skip the free when it did.

Comment thread src/ocsp/clu_ocsp.c
/* count every request a response was sent for (valid or a malformed-
* request error), so -nrequest still limits the loop even under a
* flood of malformed requests */
requestsProcessed++;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟠 [Medium] OCSP responder request-limit counts malformed requests, enabling forced early shutdown · Logic error

requestsProcessed now increments for every request that gets any response, including malformed ones, reversing the prior guard that only counted OCSP_SUCCESSFUL responses. An unauthenticated client can send nrequest malformed OCSP requests to force the responder to hit its limit and exit at line 874 before serving legitimate clients.

Fix: Only increment requestsProcessed when ocspStatus == OCSP_SUCCESSFUL, restoring the original protection.

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