我m trying to authenticate the DocuSign request in my WebHook using HMAC but the generated value does not match any of the incoming Signatures.I
使用的密钥和代码与 DocuSign 文档中的密钥和代码相同。
我的代码:
exports.ComputeHash = function (secret, payload)
{
var crypto = require('crypto');
var hmac = crypto.createHmac('sha256', secret);
hmac.write(payload);
hmac.end();
return hmac.read().toString('base64');
};
exports.HashIsValid = function (secret, payload, verify)
{
const hash = module.exports.ComputeHash(secret, payload);
console.log(hash);
return verify === hash;
};
const isValid = exports.HashIsValid("MBbMgWXqOldxxxxxxxxxkQQkNey4",
"<?xml version=\"1.0\" encoding=\"utf-8\"?><DocuSignEnvelopeInformation xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://www.docusign.net/API/3.0\"><EnvelopeStatus><RecipientStatuses><RecipientStatus>.....",
"MdXRWHj2NuBY89kEpeD7llB+RBhTxbpHfaICfjc5GME=")
console.log(isValid);
我的payload生成的哈希是“SFK+pPxbCXOTIL9jZH6oi4vC1XBgoy16aoKrVO4IIi8=”。