Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Signature problem #82

Open
mlabarre opened this issue Nov 4, 2018 · 1 comment
Open

Signature problem #82

mlabarre opened this issue Nov 4, 2018 · 1 comment

Comments

@mlabarre
Copy link

mlabarre commented Nov 4, 2018

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

@tsdaita
Copy link

tsdaita commented Feb 25, 2019

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);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants