Error Unexpected end of data
when parsing a JWT
#544
Replies: 8 comments
-
Hello @mirceanis, I think the issue is because the signature format I provided is wrong. So, I updated the code at our custom
The JWT generated is So, now, the error is:
What do you suggest? Many thanks, |
Beta Was this translation helpful? Give feedback.
-
Hello @mirceanis |
Beta Was this translation helpful? Give feedback.
-
can you post an example of From a distance, I would assume that the signature is a hex string representing 64 bytes of data. return bytesToBase64url(hexToBytes(signatureString)) I don't know how your KeyManagementSystem backend encodes signatures so it is very hard to debug this remotely. If you intend to use L.E.: I marked this as |
Beta Was this translation helpful? Give feedback.
-
Thank you @mirceanis , signatureString: util.hexToBytes(signatureString): util.bytesToBase64url(util.hexToBytes(signatureString)):
And web using
What do you suggest? Many thanks, |
Beta Was this translation helpful? Give feedback.
-
It looks like the signature is 71 bytes, not 64, which suggests it's a DER encoding. const signature = new Signature(signatureString, 'hex');
const r = leftpad(signature.r.toString('hex'), 64);
const s = leftpad(signature.s.toString('hex'), 64);
return toJose({r, s}, false); |
Beta Was this translation helpful? Give feedback.
-
Thanks @mirceanis, Note: To ease debugging I am enabling just JwtMessageHandler and commenting out the other (is this ok just at Debugging time):
Your suggestions are very valuable. Please, keep it till we succeed... |
Beta Was this translation helpful? Give feedback.
-
unfortunately, I'm out of ideas. It doesn't look like it'a a problem with veramo, but a problem with the signature encoding. |
Beta Was this translation helpful? Give feedback.
-
Yes, that should be ok. Also, to help with debugging in VSCode make sure to enable sourcemaps and to include node_modules: {
type: 'node',
request: 'launch',
name: 'Jest CustomKMS test',
program: '${workspaceFolder}/node_modules/.bin/jest',
args: ['--runInBand', '--coverage=false', '--config=jest.json', 'custom.kms.test'],
console: 'integratedTerminal',
internalConsoleOptions: 'neverOpen',
disableOptimisticBPs: true,
windows: {
program: '${workspaceFolder}/node_modules/jest/bin/jest',
},
sourceMaps: true,
resolveSourceMapLocations: ['${workspaceFolder}/**', '**/node_modules/**'],
} I hope it helps |
Beta Was this translation helpful? Give feedback.
-
Bug severity
5
Describe the bug
Not able to parse a simple JWT.
To Reproduce
Steps to reproduce the behaviour:
eyJhbGciOiJFUzI1NksiLCJ0eXAiOiJKV1QifQ.eyJ2YyI6eyJjcmVkZW50aWFsU3ViamVjdCI6eyJpZGVudGl0eUFsaWFzIjoibG9jYWxob3N0OmJjZjcxMjA0LWQzMDEtNGU3OC1iNWQ3LTViNmMyMWFjNmUwMiJ9LCJAY29udGV4dCI6WyJodHRwczovL3d3dy53My5vcmcvMjAxOC9jcmVkZW50aWFscy92MSJdLCJ0eXBlIjpbIlZlcmlmaWFibGVDcmVkZW50aWFsIl19LCJuYmYiOjE2MjEzNDE3OTgsImlzcyI6ImRpZDp3ZWI6bG9jYWxob3N0OmJjZjcxMjA0LWQzMDEtNGU3OC1iNWQ3LTViNmMyMWFjNmUwMiJ9.3045022100ba25a2e0661ea63a659e19e54b36cd32f307e65fe7a44beaddfc35ea07a602670220325075c71d34d52fbc1f4abc53c655cae3748e2300b3bb990db323cfb18d1aee
Observed behaviour
Getting an exception:
'Unsupported message type'
However, when debegging the following error is the actual one:
'Unexpected end of data'
Beta Was this translation helpful? Give feedback.
All reactions