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

Fix for node 6.x. Be explicit about crypto update input encoding latin1 #1

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
language: node_js
before_install: npm i -g [email protected]
node_js:
- 0.8
- 0.10
- 4
- 6
2 changes: 1 addition & 1 deletion lib/passport-wsfed-saml2/saml.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ SAML.prototype.validateSignature = function (xml, options, callback) {
var base64cer = embeddedSignature[0].firstChild.toString();
var shasum = crypto.createHash('sha1');
var der = new Buffer(base64cer, 'base64').toString('binary');
shasum.update(der);
shasum.update(der, 'latin1');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have thumbprint running this as well, it could be extracted.
Anyway, why don't simply passing the buffer to shasum.update() and we avoid 2 convertions, the first one to binary/latin1 and the other one (internally in crypto from latin1 to buffer.

self.calculatedThumbprint = shasum.digest('hex');

// using embedded cert, so options.cert is not used anymore
Expand Down
2 changes: 1 addition & 1 deletion lib/passport-wsfed-saml2/samlp.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ var removeHeaders = function (cert) {

var sign = function (content, key, algorithm) {
var signer = crypto.createSign(algorithm.toUpperCase());
signer.update(content);
signer.update(content, 'latin1');
return signer.sign(key, 'base64');
};

Expand Down