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

Conversation

dschenkelman
Copy link

As explained here, this is a breaking change.

Every time this appears if (!decoder.Decode(env, args[0].As<String>(), args[1], UTF8)), args[1] is the encoding parameter, and UTF8 is the default.

We need to be explicit about the encoding when calling update. This means using 'latin1' which is the string that represents the previous BINARY constant.

@mcastany mcastany changed the base branch from master to recipent-check-with-logging January 20, 2017 19:49
@mcastany mcastany changed the base branch from recipent-check-with-logging to master January 20, 2017 19:53
@mcastany mcastany changed the base branch from master to recipent-check-with-logging January 20, 2017 19:58
@mcastany mcastany closed this Jan 20, 2017
@mcastany mcastany reopened this Jan 20, 2017
@mcastany mcastany merged commit bc922e1 into mcastany:recipent-check-with-logging Jan 20, 2017
@@ -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.

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

Successfully merging this pull request may close these issues.

3 participants