Skip to content

How to verify a detached JWS signature that uses b64: false? #432

Answered by panva
petkivim asked this question in Q&A
Discussion options

You must be logged in to vote

It is easier with a flattened JSON serialization.

const jws = await new FlattenedSign(new TextEncoder().encode('detached payload example'))
  .setProtectedHeader({ alg: 'RS256', b64: false, crit: ['b64'] })
  .sign(privateKey)

await flattenedVerify({ ...jws, payload: 'detached payload example' }, publicKey)
await flattenedVerify({ ...jws, payload: new TextEncoder().encode('detached payload example') }, publicKey)

It is possible with compact too but you need to add the detached payload to the token before verifying.

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by petkivim
Comment options

You must be logged in to vote
1 reply
@trasherdk
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants