I have a Lambda function, written in NodeJS, that decrypts a file using the OpenPGP library. This has worked very well for the past four months but on Thursday last week it stopped decrypting the files with the following error:
{
"errorType": "Error",
"errorMessage": "Error decrypting message: Decryption error",
"stack": [
"Error: Error decrypting message: Decryption error",
" at /opt/node_modules/openpgp/dist/node/openpgp.min.js:2:178460",
" at process.processTicksAndRejections (node:internal/process/task_queues:95:5)",
" at async ju.decrypt (/opt/node_modules/openpgp/dist/node/openpgp.min.js:2:291018)",
" at async /opt/node_modules/openpgp/dist/node/openpgp.min.js:2:345501",
" at async Promise.all (index 0)",
" at async /opt/node_modules/openpgp/dist/node/openpgp.min.js:2:344837",
" at async Promise.all (index 0)",
" at async /opt/node_modules/openpgp/dist/node/openpgp.min.js:2:344447",
" at async Promise.all (index 0)",
" at async Bh.decryptSessionKeys (/opt/node_modules/openpgp/dist/node/openpgp.min.js:2:344404)"
] }
The odd thing is that when I debug the Lambda function locally it still successfully decrypts the file. I have run the function for files that were previously decrypted successfully and they no longer decrypt. I have run the code using the same libraries I’m using locally, but it still fails.
I’m wondering why this can work locally but not from AWS and also why it would have stopped working in the first place given there were no code changes.
2
Answers
It seems, it started to fail when AWS Lambda runtime upgraded the runtime from 18.v21 to 18.v26. You shall try downgrading the version to 18.v21 if possible.
Ref: https://github.com/openpgpjs/openpgpjs/discussions/1749
We experienced this as well the last v18.21 was the last working version. However in testing if you can migrate to v20 runtime openpgp 5.11.1 works. There are some significant changes in the library from 4.10 to 5.11 but encryption and decryption are working in the latest release of openpgp