Fix malformed AKID extension from wolfSSL_X509_set_authority_key_id()#10370
Open
cconlon wants to merge 1 commit intowolfSSL:masterfrom
Open
Fix malformed AKID extension from wolfSSL_X509_set_authority_key_id()#10370cconlon wants to merge 1 commit intowolfSSL:masterfrom
cconlon wants to merge 1 commit intowolfSSL:masterfrom
Conversation
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #10370
Scan targets checked: wolfssl-bugs, wolfssl-src
No new issues found in the changed files. ✅
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes malformed Authority Key Identifier (AKID) extensions produced by wolfSSL_X509_set_authority_key_id() by ensuring the encoder emits the RFC 5280 AuthorityKeyIdentifier ::= SEQUENCE { [0] keyIdentifier } wrapping rather than writing raw keyId bytes directly.
Changes:
- Update
wolfSSL_X509_set_authority_key_id()to store the keyId inauthKeyId(notauthKeyIdSrc), preserving correct encoder wrapping behavior. - Add DER round-trip API tests validating the AKID inner structure for both
_set_authority_key_id()and_ex(). - Add overwrite/cleanup tests to exercise prior-AKID storage replacement paths, and register the new tests.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/x509.c |
Adjusts AKID setter memory/field usage so encoding produces correctly wrapped AuthorityKeyIdentifier per RFC 5280. |
tests/api.c |
Adds round-trip + overwrite tests that sign, serialize, re-parse, and validate AKID DER framing and replacement behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR fixes a malformed AKID extension produced by
wolfSSL_X509_set_authority_key_id().wolfSSL_X509_set_authority_key_id()was writing the raw key id intoauthKeyIdSrc, which madeCopyX509ToCertsetcert->rawAkid = 1and suppress theSEQUENCE { [0] keyId }wrapper in the encoder template. The resulting AKID extension's OCTET STRING contained the bare key id bytes, which parsers reject.We adjust to set
authKeyIdonly here, letting the encoder template wrap the bytes per RFC 5280 4.2.1.1.Discovered via wolfJSSE user report. Original code for this (aafc876759) was added for the same end user, so I don't expect any backwards compatibility issues with this "corrected" behavior.
Testing
New
tests/api.cround-trip tests covering bothwolfSSL_X509_set_authority_key_id()and_exthat sign, re-parse, and assert theSEQUENCE { [0] keyId }framing, plus an overwrite test that exercises the cleanup branches when the setter is called on a cert with priorauthKeyIdorauthKeyIdSrcstorage.Checklist