Error during decrypting
Occasionally while using the JWE.decrypt function call, I get the following error:
{ message: 'no key found',
stack: 'Error: no key found\n at processKey (/home/ubuntu/node_modules/node-jose/lib/jwe/decrypt.js:176:22)\n at <anonymous>' }
This error appears even though the private key exists in the right location.
Sample code shown:
let importkeystore = jose.JWK.createKeyStore();
importkeystore.add(privatePemData, 'pem').then(function (result) {
jose.JWE.createDecrypt(result).decrypt(JSON.parse(encryptedData)).
then(function (decryptedData) {
......
});
Appreciate the help in this regards.
Upon analysis, below could be the root cause for the decrypt error:
(node:731) UnhandledPromiseRejectionWarning: Error: Invalid RSAES-OAEP padding.
at Object.pkcs1.decode_rsa_oaep (/home/root/node_modules/node-forge/lib/pkcs1.js:255:11)
at Object.decode (/home/root/node_modules/node-forge/lib/rsa.js:1190:30)
at Object.key.decrypt (/home/root/node_modules/node-forge/lib/rsa.js:1200:19)
at fallback (/home/root/node_modules/node-jose/lib/algorithms/rsaes.js:137:21)
at Object.exports.decrypt (/home/root/node_modules/node-jose/lib/algorithms/index.js:109:10)
at JWKBaseKeyObject.value (/home/root/node_modules/node-jose/lib/jwk/basekey.js:696:25)
at /home/root/node_modules/node-jose/lib/jwe/decrypt.js:191:31
at <anonymous>
(node:731) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
Added the kid as part of the key while adding to the keystore as well.
The above promise rejection warning is being thrown on this line in decrypt.js - return algKey.unwrap(rcpt.header.alg, prekey, rcpt.header);
@linuxwolf / @panva : Appreciate your help in this regard.
@Vishal8523 did you found the solution to this?
@linuxwolf @panva can you please help I'm also facing similar issue?
no. Issue still exists. just use jose CLI
server run is right local run is fail