Skip to content

Misc fixes - #50

Merged
yosuke-wolfssl merged 10 commits into
wolfSSL:mainfrom
Frauschi:misc
Oct 13, 2026
Merged

yosuke-wolfssl merged 10 commits into
wolfSSL:mainfrom
Frauschi:misc

Conversation

@Frauschi

@Frauschi Frauschi commented Oct 9, 2026 •

Copy link
Copy Markdown
Member

Follow-ups found while trimming the comments in #49.

  • No-malloc tests pass the static pool to wolfcert_init, so wolfCert's own heap-hint path is exercised with a pool.
  • The last-error state uses wolfSSL's THREAD_LS_T: per-thread with HAVE_THREAD_LS, global otherwise. It was silently global on macOS, where Apple clang defines __STDC_NO_THREADS__. On Zephyr it leaves .tbss (340 to 44 bytes on the qemu_x86 sample), so the Kconfig no longer implies THREAD_LOCAL_STORAGE. test_smoke checks it across two threads.
  • EST test server: the Basic credential, the request's Authorization value and the raw header buffer are zeroed after use, and the chunk copy bound no longer relies on an addition that can wrap on 32-bit.
  • enroll_scep example requires the CA's SHA-256 fingerprint and checks it before enrolling.
  • The EST TLS roundtrip's subject assert could not fail; it now compares the issued CN.
  • build-wolfssl.sh stops on an unknown config instead of building with no flags.
  • Docs: the WolfCertKeyCfg.param comment, and the README notes the missing tls-unique binding (RFC 7030 section 3.5).

API changes:

  • WolfCertCertMeta.csr_attributes_der is removed, which changes the struct layout. wolfcert_csr_build never encoded it, so callers lost their attributes silently; use the customize callback or wolfcert_csr_attrs_apply.
  • WOLFCERT_NO_THREAD_LOCAL is gone. Builds whose wolfSSL settings come from user_settings.h need HAVE_THREAD_LS for per-thread error state (examples/user_settings.h.example notes it).

test_static_mem_init() set wolfCert's default heap, then every test's
wolfcert_init(NULL) reset it to NULL. The no-malloc tests still passed
because wolfSSL falls back to its global heap hint, so wolfCert's own
heap-hint plumbing was never exercised with a pool. The tests now hand
the pool to wolfcert_init through test_heap_hint().
The last-error state used __thread on GCC and Clang unless
__STDC_NO_THREADS__ was defined. Apple clang defines it, so the state was
global on macOS while the docs said it was per-thread.

It now uses wolfSSL's THREAD_LS_T: per-thread when wolfSSL is built with
HAVE_THREAD_LS, which its configure enables where the compiler supports
it, and one global otherwise. wolfSSL also leaves THREAD_LS_T empty under
NO_THREAD_LS and on FreeRTOS and Zephyr, and the docs say so. This drops
WOLFCERT_NO_THREAD_LOCAL.

On Zephyr the ~300-byte state therefore no longer sits in .tbss, which
Zephyr copies onto every thread's stack (qemu_x86 sample: 340 to 44
bytes). The Kconfig no longer implies THREAD_LOCAL_STORAGE, and the
README's idle-stack sizing note is gone.

test_smoke checks that an error on a second thread does not show up on
the first, wherever THREAD_LS_T is thread-local; it failed on macOS
before this change.

examples/user_settings.h.example notes HAVE_THREAD_LS for hosted targets
whose wolfSSL settings share the file.
@Frauschi Frauschi self-assigned this Oct 9, 2026
Copilot AI balanced review requested due to automatic review settings October 9, 2026 13:59
@Frauschi Frauschi changed the title Misc Misc fixes Oct 9, 2026

Copilot AI 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.

🟡 Changes recommended

SCEP pinning remains optional and Basic credentials can still persist in the request buffer after cleanup.

2 open findings
What changed in this PR

This PR applies follow-up correctness, security, testing, API, and documentation improvements identified during PR #49.

Changes:

  • Aligns last-error storage with wolfSSL thread-local behavior and reduces Zephyr TLS overhead.
  • Exercises static heap hints and strengthens EST parsing, authentication cleanup, and certificate assertions.
  • Removes an unused public field and adds SCEP fingerprint support plus documentation updates.
File Description
zephyr/​samples/​wolfcert_est_client/​boards/​frdm_mcxn947_mcxn947_cpu0.conf Removes obsolete TLS stack allowance.
zephyr/​README.md Removes obsolete per-thread TLS sizing guidance.
zephyr/​Kconfig Stops implying thread-local storage.
zephyr/​CMakeLists.txt Removes the retired TLS override.
wolfcert/​types.h Clarifies key parameters and removes unused CSR fields.
wolfcert/​status.h Documents wolfSSL-dependent error-state behavior.
tests/​unit/​test_transport.c Passes the static heap hint.
tests/​unit/​test_store.c Passes the static heap hint.
tests/​unit/​test_smoke.c Tests heap initialization and per-thread errors.
tests/​unit/​test_server_ca_store.c Passes the static heap hint.
tests/​unit/​test_scep_msg.c Passes the static heap hint.
tests/​unit/​test_parse_negative.c Passes the static heap hint.
tests/​unit/​test_keygen.c Passes the static heap hint.
tests/​unit/​test_est.c Passes the static heap hint.
tests/​unit/​test_csr.c Passes the static heap hint.
tests/​unit/​test_csr_attrs.c Passes the static heap hint.
tests/​test_static_mem.h Exposes the test pool’s heap hint.
tests/​integration/​test_est_tls_roundtrip.c Validates issued certificate CNs.
tests/​CMakeLists.txt Links the smoke test with thread support.
src/​internal.c Uses wolfSSL’s thread-local qualifier.
src/​est/​est_server.c Hardens chunk bounds and credential cleanup.
scripts/​ci/​build-wolfssl.sh Propagates unknown-configuration failures.
README.md Documents missing tls-unique binding.
Makefile.am Links the smoke test with pthreads.
examples/​user_settings.h.example Documents HAVE_THREAD_LS.
examples/​enroll_scep.c Adds optional CA fingerprint verification.
docs/​MIGRATING-FROM-WOLFSCEP.md Corrects error-state terminology.
docs/​EMBEDDED.md Documents global error-state fallback.
docs/​ARCHITECTURE.md Updates error-state architecture guidance.
CONTRIBUTING.md Removes obsolete TLS sizing advice.
AGENTS.md Updates integration guidance for error state.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread examples/enroll_scep.c Outdated
Comment thread src/est/est_server.c
check_basic_auth() left the plaintext user:pass in a stack buffer and
freed the base64 copy without zeroing it. The request's Authorization
value is now zeroed before it is freed, and so is the stack buffer
parse_request() reads the header block into.
The decode pass checked ri + csz and body_sz + csz, which can wrap on a
32-bit size_t. chunked_body_complete() already rejects any chunk that
does not fit before the decode pass runs, so this was not reachable, but
the check should not depend on that. The client decoder in http.c
already uses this form.
GetCACert is unauthenticated over plain HTTP, and the example went
straight from it to PKCSReq. It now requires the CA's SHA-256
fingerprint as its third argument and checks it with
wolfcert_scep_verify_ca_fingerprint before enrolling. The migration
guide no longer describes the example as lacking the check.
The assert on the issued certificate's subject was ORed with
issued.len > 0 and so could not fail. It now decodes the certificate
and compares the subject CN.
wolfcert_csr_build never put it into the CSR, so callers setting it had
their attributes dropped without an error. wolfSSL's CSR encoder has no
way to pass raw attributes through; the customize callback and
wolfcert_csr_attrs_apply cover what it was meant for.

This changes the layout of WolfCertCertMeta.
For ECC it is the curve size in bits (256, 384, 521), not a curve id.
RFC 7030 section 3.5 has the client put tls-unique into the CSR and the
server check it. wolfCert does neither, and TLS 1.3 does not define
tls-unique.
resolve_flags ran in a process substitution, so its exit 2 only ended
the subshell and the script went on to build with no configure flags.
@Frauschi

Frauschi commented Oct 9, 2026

Copy link
Copy Markdown
Member Author

@wolfSSL-Fenrir-bot review balanced

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

Scan targets checked: wolfcert-src, wolfcert-bugs
Coverage: 6 of 14 in-scope changed file(s) opened by the reviewer; not opened: tests/unit/test_csr.c, tests/unit/test_csr_attrs.c, tests/unit/test_keygen.c, tests/unit/test_parse_negative.c, tests/unit/test_scep_msg.c, tests/unit/test_server_ca_store.c, tests/unit/test_store.c, tests/unit/test_transport.c

Fenrir result: Approved ✅

No new issues found in the changed files.

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

Review tier: Balanced

@yosuke-wolfssl yosuke-wolfssl 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.

Looks good to me and any tool didn't find blocking issues.

@yosuke-wolfssl
yosuke-wolfssl merged commit 89af626 into wolfSSL:main Oct 13, 2026
28 checks passed
@Frauschi
Frauschi deleted the misc branch October 13, 2026 06:41
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.

5 participants