Skip to content

More minor fixes - #51

Open
Frauschi wants to merge 8 commits into
wolfSSL:mainfrom
Frauschi:misc_fixes_2
Open

Frauschi wants to merge 8 commits into
wolfSSL:mainfrom
Frauschi:misc_fixes_2

Conversation

@Frauschi

@Frauschi Frauschi commented Oct 9, 2026 •

Copy link
Copy Markdown
Member

Various more minor fixes identified while doing the comment trimming of #49:

  • SCEP server matches header names exactly (Content-Length-Foo set the body length) and rejects whitespace before the colon. Header and keyword comparisons no longer fold case by the C locale, so there is no strncasecmp left in src/.
  • wolfcert_csr_build rejects a C or serialNumber that is not a PrintableString, and an emailAddress with bytes above 0x7F, with WOLFCERT_ERR_BAD_ARG, instead of emitting malformed DER.
  • SCEP CLI enroll and getcert check the GetCACaps result: a non-200 reply warns and continues as a CA without capabilities, and any other failure stops the command.
  • wolfcert_scep_parse_pki_message rejects an attribute whose tag or length is cut short instead of skipping it as absent, tells truncated, empty and unallocated attributes apart, and returns WOLFCERT_ERR_MEMORY on allocation failure, which the SCEP server answers with 500.
  • CSR signing falls back from SHA-384/512 when wolfSSL lacks them (P-521 takes SHA-384 when only SHA-512 is missing) instead of failing to sign.
  • The CA store test declares nanosleep (GCC 14+ rejects the implicit declaration under -std=c11).
  • The monotonic clock and deadlines are 64-bit, so they no longer wrap after 24.8 days of uptime on 32-bit hosts.
  • The Zephyr workspace action passes its inputs through env instead of expanding them into scripts, and retries the SDK download.

Behaviour changes: CSR subjects with the invalid values above now fail, and the SCEP CLI stops on GetCACaps transport errors.

The SCEP server compared header names with a prefix strncasecmp, so a
Content-Length-Foo field set the body length. It now uses the EST
server's exact match, moved to http.c as wolfcert_http_hdr_is, and
rejects whitespace before the colon (RFC 9112 section 5.1) like the EST
server does.

strncasecmp also folds case by the C locale, which breaks on a Turkish
locale where 'I' does not lower to 'i'. The SCEP server's Connection
value, the SCEP client's GetCACaps keywords and the EST server's Basic
scheme now use wolfcert_ascii_ncasecmp, which leaves no strncasecmp in
src/ and lets the three files drop <strings.h>.
wolfSSL encodes the country and serialNumber RDNs as PrintableString,
and wolfcert_csr_build copied any value into them, so "C=U_" or a
serialNumber with '@' produced malformed DER. Both now fail with
WOLFCERT_ERR_BAD_ARG.

emailAddress, which wolfSSL encodes as IA5String, now rejects bytes
above 0x7F the same way.
enroll and getcert ignored the return of wolfcert_scep_get_ca_caps. A
non-200 reply still means a CA without capabilities and the command
goes on, now with a warning that the content cipher falls back to 3DES
unless --content-cipher is given. Any other failure, such as an I/O or
TLS error, stops the command instead of enrolling with empty caps.
@Frauschi Frauschi self-assigned this Oct 9, 2026
Copilot AI balanced review requested due to automatic review settings October 9, 2026 14:02

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

Some truncated SCEP attribute encodings are still treated as absent instead of protocol errors.

1 open finding
What changed in this PR

Improves protocol parsing, CSR validation, timeout safety, CLI error handling, and CI reliability.

Changes:

  • Tightens SCEP/HTTP parsing and allocation-error handling.
  • Validates CSR fields, adds hash fallbacks, and uses 64-bit deadlines.
  • Expands tests and hardens Zephyr workflow input handling.
File Description
wolfcert/​types.h Documents signature-hash fallback behavior.
tests/​unit/​test_server_ca_store.c Enables the POSIX nanosleep declaration.
tests/​unit/​test_scep_msg.c Tests malformed attributes and allocation failures.
tests/​unit/​test_csr.c Tests CSR validation and ECC signature selection.
tests/​integration/​test_scep_roundtrip.c Tests strict HTTP header parsing.
src/​scep/​scep_server.c Tightens headers and maps OOM to HTTP 500.
src/​scep/​scep_msg.c Distinguishes attribute errors and allocation failures.
src/​scep/​scep_client.c Uses locale-independent capability matching.
src/​net_posix.c Converts monotonic deadlines to 64-bit values.
src/​internal.h Updates internal deadline and header APIs.
src/​http.c Adds shared exact header-name matching.
src/​est/​est_server.c Reuses header matching and 64-bit deadlines.
src/​csr.c Validates ASN.1 strings and supports hash fallback.
cli/​wolfcert_client.c Handles GetCACaps failures explicitly.
.github/​actions/​zephyr-workspace/​action.yml Safely passes inputs and retries SDK downloads.

🧠 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 src/scep/scep_msg.c Outdated
wolfcert_scep_parse_pki_message reported an attribute value that
overruns its SET as "multi-valued", and a failed copy of an attribute or
the signer certificate returned WOLFCERT_OK with the output left NULL,
which surfaced later as a misleading AUTH or "Bad Message" error. A
truncated value now has its own message, an empty one is rejected
before it reaches XMALLOC(0), and an allocation failure returns
WOLFCERT_ERR_MEMORY, which the SCEP server answers with 500.

A value whose tag or length was cut short (e.g. 13, or 13 81) was
skipped as if the attribute were absent, so the parse could still
return WOLFCERT_OK. The SET and value headers are now read with
der_read_tlv(), which also bounds the value by its SET and handles every
definite length form instead of only 81 and 82, and any header it
rejects is reported as truncated.

test_parse_reports_oom fails each allocation in turn and requires every
output to stay NULL and the result to be WOLFCERT_ERR_MEMORY, unless the
failure came back from wolfSSL's PKCS#7 verify, which can report a
failed allocation as a parse error. test_text_attrib_truncated covers
the cut tag, the cut 81 and 82 lengths, an indefinite length, a cut SET
length and a value overrunning its SET.
The CSR signature type picked SHA-384 for P-384 and SHA-512 for P-521,
and honoured a preferred_hash of 384 or 512, without checking the
wolfSSL build had those hashes, so signing failed on a build without
them (est_csr_attrs_apply_roundtrip fails on main against one). Those
choices now fall back to the key type's default, except that P-521
takes SHA-384 when only SHA-512 is missing.

test_csr checks the hash of a P-256, P-384 and P-521 CSR against what
the wolfSSL build provides.
test_server_ca_store.c includes tls_test_util.h, which calls nanosleep,
but did not define _POSIX_C_SOURCE like the other tests that include
it. Under -std=c11 glibc then hides the prototype, and GCC 14 and newer
reject the implicit declaration.
wolfcert_mono_ms and the deadlines built on it were long, which on a
32-bit POSIX host wraps after about 24.8 days of uptime and then breaks
the server's request deadline, the PHA wait and the client connect
timeout.
The zephyr-workspace action expanded ${{ inputs.* }} straight into run
scripts; they now reach the shell as environment variables. The SDK
download also retries transient server errors, which have failed the
qemu_x86 job before.
@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 #51

Scan targets checked: wolfcert-src, wolfcert-bugs
Coverage: 6 of 10 in-scope changed file(s) opened by the reviewer; not opened: src/scep/scep_client.c, tests/unit/test_csr.c, tests/unit/test_server_ca_store.c, wolfcert/types.h

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

@Frauschi Frauschi assigned wolfSSL-Bot and unassigned Frauschi Oct 9, 2026
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