Reputation: 21
I am trying to verify a jws with node-jose, but no matter what I do, I get an Error: no key found
.
I believe the issue might come from the fact that my jwks do not have a k
parameter. But that is the key I have, I must verify the jws with the key as it is.
(The algorithm used is PS256
if it might help, the only dependency is node-jose, I modified the payload and signature in the jws and the n
of the jwks for the example)
const jws = 'eyJhbGciOiJQUzI1NiIsICJraWQiOiJzY2RfNzhlZDdkMmJmMmE4YzRhZjRhM2QzNjUyYTg5ZmU4YjlmNDZhZGRiOGJjOGU3Y2I2OTEwNmE2NDY3OTAwZjVlNiJ9.lcnNcIjpbXSxcImRvY3VtZW50c1wiOltdLFwiaW5zdHJ1Y3Rpb25zXCI6e1wic2lnbmF0dXJlc1wiOltdLFwicmV2aWV3c1wiOltdLFwiY2FwdHVyZXNcIjpbXSxcInNlcXVlbmNpbmdcIjpbXSxcImVkaXRpb25zXCI6W119LFwiYWN0aW9uc1wiOltdLFwibWV0YWRhdGFcIjp7fSxcInByb2dyZXNzX3ZhbHVlXCI6MCxcIm9uZ29pbmdfY29udmVyc2F0aW9uXCI6ZmFsc2UsXCJoYXNfdW5yZWFkX21lc3NhZ2VcIjpmYWxzZSxcIm9yaWdpblwiOlwid2ViYXBwXCIsXCJjYXJib25fY29waWVzXCI6W10sXCJ1cGxvYWRzXCI6W10sXCJwcml2YXRlXCI6ZmFsc2V9fX1cbiI.g0hFgJZWjJKEkTAAzQY_4zB_upsoXV2xctXphB-v-2b_X0ix9RHjC1SdrqVd-MEnpT_JVu7v_F7UNbV5V04tPxNPTtmbiljonSFKWycvP1cH';
const jwks = {
'kid': 'scd_78ed7d2bf2a8c4af4a3d3652a89fe8b9f46addb8bc8e7cb69106a6467900f5e6',
'e': 'AQAB',
'use': 'sig',
'n': 'ANLACfctp63s33a3IZcErwyJRklUw1ew8ve8DSgE3MS3MWQdnzg1ZEwpH0lvir-v3zmesu900xQ2LToYJLhYYY6-S8LTVRy4DgNFdacqCj2yr1LnLugte7qdqZatQ-_teWygQo8ye83yiAnfSD19QJhdT577LUfpj8uFKI0TZTqvDBMnQ4-Yk9yN5jUsMpPvNiufhtTeqIcnXkPjXEe-gnD0t8C7aUHQJhryYsuFshbiQPo6xmR_D71SU3lV9I36mBG7O',
'kty': 'RSA'
};
const key = await jose.JWK.asKey(jwks, 'json');
const result = await jose.JWS.createVerify(key).verify(jws);
I tried many ways of creating the key (keystore from jose.JWK.asKeyStore, JSON, etc), but i got the same error.
Upvotes: 2
Views: 686