You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi
I use node-http-signature to sign request. The request is sent to a Java tomcat application. In this one I use Tomitribe Http-Signature project. This one failed on signature verification.
After code debugging I think there is a little error in Signer.js in the WriteHeader :
RequestSigner.prototype.writeHeader = function (header, value) {
assert.string(header, 'header');
header = header.toLowerCase();
assert.string(value, 'value');
this.rs_headers.push(header);
if (this.rs_signFunc) {
this.rs_lines.push(header + ': ' + value);
} else {
var line = header + ': ' + value;
if (this.rs_headers.length > 0)
line = '\n' + line;
this.rs_signer.update(line);
console.log(line);
}
return (value);
};
Your test if (this.rs_headers.length > 0)
is always true because you push header first...
Thanks
The text was updated successfully, but these errors were encountered:
As @mlabarre pointed above you are adding a new line even when a single element exists. The fix is minor, add the newline only if the number of elements are more than one.
Calling the writeHeader
signature.writeHeader('host', host); => first entry adds the newline before causing incorrect signature
signature.writeDateHeader();
signature.writeTarget(request.method, request.path);
Hi
I use node-http-signature to sign request. The request is sent to a Java tomcat application. In this one I use Tomitribe Http-Signature project. This one failed on signature verification.
After code debugging I think there is a little error in Signer.js in the WriteHeader :
Your test
if (this.rs_headers.length > 0)
is always true because you push header first...
Thanks
The text was updated successfully, but these errors were encountered: