Skip to content

Fix an issue with parsing headers with 'kid' - #395

Merged
simo5 merged 2 commits into
latchset:mainfrom
simo5:kid_in_headers
Sep 1, 2026
Merged

Fix an issue with parsing headers with 'kid'#395
simo5 merged 2 commits into
latchset:mainfrom
simo5:kid_in_headers

Conversation

@simo5

@simo5 simo5 commented Aug 31, 2026

Copy link
Copy Markdown
Member

This addresses an issue with JWS reported by @1321284827 and also brings up the related JWE feature to properly handle kid in per-recipient headers just like we support kid for multiple JWS signatures.

In both cases we had issues, but the JWE case was non-functional, while the JWS cases was problematic.

@simo5
simo5 requested a review from rjeffman August 31, 2026 20:23
simo5 added 2 commits August 31, 2026 16:34
When verifying a JWS against a JWKSet, check for the 'kid'
parameter in chk_hdrs instead of self.jose_header. This
ensures that key lookup works properly for signatures that
define 'kid' in unprotected headers or when processing
multiple signatures.

Assisted-by: Gemini:Gemini 3.7 Flash
Signed-off-by: Simo Sorce <simo@redhat.com>
Update JWE header parsing and decryption to properly support objects with
multiple recipients.

The `jose_header` property now returns a list of headers when multiple
recipients exist, and JWKSet key lookups now evaluate the individual
recipient's header rather than the top-level property. Additionally, allow
`_get_jose_header` to accept headers that are already decoded as dictionaries.

Assisted-by: Gemini:Gemini 3.7 Flash
Signed-off-by: Simo Sorce <simo@redhat.com>

@rjeffman rjeffman left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@simo5
simo5 merged commit 746edb9 into latchset:main Sep 1, 2026
16 checks passed
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.

2 participants