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

@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 Outdated
Comment thread src/x509/clu_ca_setup.c
Comment thread src/ocsp/clu_ocsp.c
Comment thread src/ecparam/clu_ecparam.c Outdated
Comment thread src/x509/clu_ca_setup.c
Comment thread src/ocsp/clu_ocsp.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-src
Failed targets: wolfclu-bugs
Findings: 3
2 finding(s) posted as inline comments (see file-level comments below)

High (1)

Heap buffer overflow copying PEM-to-DER key material into fixed-size scratch buffers

File: src/x509/clu_x509_sign.c:436
Function: wolfCLU_GenChimeraCertSign
Category: Buffer overflows

caKeyBuf/serverKeyBuf/sapkiBuf/altCaKeyBuf are fixed LARGE_TEMP_SZ (11264-byte) allocations, but after wc_PemToDer the code copies derObj->length bytes into them with no check that derObj->length <= LARGE_TEMP_SZ, at lines 435-436, 482-483, 528-529, and 562-563.

Recommendation: Reject with an error if derObj->length exceeds the destination buffer capacity before each XMEMCPY.

Referenced code: src/x509/clu_x509_sign.c:436-438 (3 lines)


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

Comment thread src/ocsp/clu_ocsp.c
CHECK(wolfCLU_PathsRefEqual("same.txt", "same.txt") == 1, "PathsRefEqual identical");
CHECK(wolfCLU_PathsRefEqual("a.txt", "b.txt") == 0, "PathsRefEqual different");

f = fopen("test_ref_equal.tmp", "wb");

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] Hardcoded temp filename in PathsRefEqual unit test not PID-scoped · Hardcoded paths, ports, or environment dependencies

test_ref_equal.tmp is a fixed filename in the CWD, unlike the sibling testReadFileToBuffer which PID-scopes its temp file; concurrent/parallel test runs in the same directory can collide.

Fix: Use a PID- or tmpnam-scoped filename as done in testReadFileToBuffer.

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