kms.decrypt is throwing TypeError: Not a buffer error
See original GitHub issueWhen implementing kms.decrypt function and the the parameter ciphertextBlob obtained from kms.generateDataKey function is set as a value for the property CiphertextBlob on params object is showing the next error:
TypeError: Not a buffer at TypeError (native) at new Hmac (crypto.js:87:16) at Object.Hmac (crypto.js:85:12) at sign (/home/vagrant/node_modules/jwt-simple/lib/jwt.js:177:24) at verify (/home/vagrant/node_modules/jwt-simple/lib/jwt.js:162:27) at Object.jwt_decode [as decode] (/home/vagrant/node_modules/jwt-simple/lib/jwt.js:97:10) at /var/www/project/controllers/validation.js:81:28 at Response.<anonymous> (/var/www/project/services/aws/kms.js:48:5) at Request.<anonymous> (/home/vagrant/node_modules/aws-sdk/lib/request.js:355:18) at Request.callListeners (/home/vagrant/node_modules/aws-sdk/lib/sequential_executor.js:105:20)
This is the implementation:
function(ciphertextBlob, callback){
console.log('is Buffer: ', Buffer.isBuffer(ciphertextBlob)); //true
var blobString = ciphertextBlob.toString('base64');
console.log('CiphertextBlob blobString : ', blobString); //posible string argument
var params = {
CiphertextBlob: ciphertextBlob
};
kms.decrypt(params, function(err, data) {
if (err) 'Error on KMS decrypt: ' + err;
callback(data);
});
};
Issue Analytics
- State:
- Created 7 years ago
- Comments:8 (3 by maintainers)
@chrisradek It works fine, I just added the region on the constructor for your code:
Thanks a lot for your help.
@alexosunas What version of the SDK are you using, and what environent? (node.js version or browser). Using the latest version of the SDK in node 0.12.x, this code is working for me: