Correct the locality key length in the subject DN table - #16
Correct the locality key length in the subject DN table#16yosuke-wolfssl wants to merge 1 commit into
Conversation
- The rdn_fields row for L records a key length of 1, matching the one-character key, so assign_rdn's length-equality test selects it. - build_with_extras carries L=Portland in its subject DN and asserts dc.subjectL against dc.subjectLLen on the parsed request. Fixes F-8012.
There was a problem hiding this comment.
Pull request overview
Fixes CSR subject-DN parsing for the locality attribute (L=) by correcting the key-length metadata used during RDN matching, and adds a unit test to prevent regressions. This aligns with wolfCert’s CSR-building path (used by both EST and SCEP) and ensures subject DNs containing L= are accepted.
Changes:
- Correct
rdn_fieldsmetadata so"L"is matched with length1(not2) during subject-DN parsing. - Extend the existing CSR unit test to include
L=Portlandand assert it round-trips intoDecodedCert.subjectL/subjectLLen.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/csr.c | Fixes locality (L) key-length in the subject DN attribute table so L= matches correctly. |
| tests/unit/test_csr.c | Adds coverage to ensure L= is parsed and preserved in the generated CSR. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #16
Scan targets checked: none
Failed targets: wolfcert-bugs, wolfcert-src
Problem
src/csr.cmatches subject-DN attribute keys against a table that records a keystring and its length per row. The locality row recorded a length of 2 for the
one-character key
"L":{ "L", 2, offsetof(CertName, locality), CTC_NAME_SIZE },assign_rdnselects a row only whenrdn_fields[i].key_len == klen, soL(length 1) never matched any row, fell through to
WOLFCERT_ERR_UNSUPPORTED, andparse_subject_dnpropagated that to the caller. Every other row was correct.Any subject DN containing
L=therefore failed to build a CSR at all:CN=device-1,O=Acme,L=Portland,C=USreturns-12before any network traffic, onboth EST and SCEP, library and CLI. Closes f-8012.
Fix (
src/csr.c)Record the locality key length as
1. The matcher is unchanged:assign_rdn'skey/klenis a pointer into the caller's DN plus a length, not aNUL-terminated string, and the existing form compares exactly
klenbyteswithout ever indexing
key[klen].src/ca_issue.calready copiessubjectLon issuance, so the locality nowsurvives the full CSR to issued-cert round trip with no second change.
Tests (
tests/unit/test_csr.c)Extended
build_with_extrasrather than adding a binary: its subject DN carriesL=Portland, and the reparsed request is asserted againstdc.subjectLanddc.subjectLLen. wolfSSL'sDecodedCertname fields point into the DER and arenot NUL-terminated, hence the explicit length rather than
strcmp.Verification
csrfails before the fix and passes after, confirmed by reverting onlysrc/csr.cand rebuilding.