Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error during decrypting #309

Open
Vishal8523 opened this issue Mar 23, 2021 · 5 comments
Open

Error during decrypting #309

Vishal8523 opened this issue Mar 23, 2021 · 5 comments

Comments

@Vishal8523
Copy link

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.

@Vishal8523
Copy link
Author

Vishal8523 commented Apr 8, 2021

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.

@yashgehi
Copy link

@Vishal8523 did you found the solution to this?

@yashgehi
Copy link

@linuxwolf @panva can you please help I'm also facing similar issue?

@Vishal8523
Copy link
Author

no. Issue still exists. just use jose CLI

@irabbit666666
Copy link

server run is right local run is fail

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

No branches or pull requests

3 participants