Fix decryption failure for entire payload when request object is encr… #64
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix decryption failure for entire payload when request object is encryptedData and response is encryptedResponse
The decryption process failed for the entire payload when the request object was encryptedData and the response was encryptedResponse from the API. This issue occurred due to a conditional statement that incorrectly retrieved the encrypted value.
Link to issue/feature request: add the link here
Here is the scenario:
When encrypting the entire payload and assigning it to encryptedData, and subsequently making an API call, the response is received as an encryptedResponse object. In this case, while decrypting response object an error is thrown due to invalid input.
My config
{
"path": "/entirepayload",
"toEncrypt": [{ "element": "$", "obj": "$" }],
"toDecrypt": [{ "element": "encryptedResponse", "obj": "$" }],
"mode": "JWE",
"encryptedValueFieldName": "encryptedData",
"publicKeyFingerprintType": "certificate",
"dataEncoding": "base64",
"encryptionCertificate": "./test/res/test_certificate.cert",
"privateKey": "./test/res/test_key.der"
}
Sample response I recived from API:
{
encryptedResponse: 'eyJraWQiOiJnSUVQd1RxREdmenc0dXd5TElLa3d3UzNnc3c4NW5FWFkwUFA2QllNSW5rPSIsImN0eSI6ImFwcGxpY2F0aW9uL2pzb24iLCJhbGciOiJSU0EtT0FFUC0yNTYiLCJlbmMiOiJBMjU2R0NNIn0.' +
'flEVAmFsw70aH6cyCmU8PmJSGBjWM8QU8rQg2IvfHZjvBq0O7qtRjIn9ssmTlYAohXxO4uIuECUWv9NILdZnKd20wtgihBmrflKVhVZ8afJESFIEcF4vIY03QBou0u4bGVNtrC0XooPy6uRnkZzlcvDZyMVMJF4eEK1-PSx7Gf77Vj9q37S' +
'IHsVCo4EujDi6Y1qRz2kI86eIguLeJbFmL1VcOUyrt8jtjcj00utFm30j-PyOEwgiyhYI6F0eMUWT89d-QYQrInk-Ciyp4bYwsLcr85BOMqWZ8nc2CGu2rfBNGexCphxDUJQ/TWEBZ0XKBAaQOj5qszwXhO-synLJ3A.eIGqscNMcz5h8x8w26oc6A.' +
'y-66zjYqTEqmgV39rklNVKgCF1Uq6jf-sLKOOkkX6RZJsAl4UY4cHWEfWcJCgnMnS8ZE/sBen24FwjZrxlC/znJa4D-BoY4OK0oE/GQJZ9mkmzwbqKeBFLzmalVLG2/XH74TY6bVn5xtVSR9tCalEMjIEo/Wwyt1DbIdysFqfcmXUbJo4bmKx6rfpBbXn' +
'cOopJ8nxQZaXueM1BcZQykS8bl4GriF2NgtPdjz6aqXsxDihd3p7LpbobrdcFtZvsMTs6xTRia9q9qqzN70cKwM8lBftMdRovRa-JCrkJ7LDqDQ/A.cdFqkuHXnggBcfxugl8cBA'
}
This encapsulates the issue description along with the provided configuration and a sample response from the API.