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

SignFinal error no longer returned, instead returning a PEM routines:PEM_read_bio:no start line error #408

Closed
Labels
crypto Issues and PRs related to the crypto subsystem.

Comments

@ryanseys
Copy link
Contributor

In fooling around with iojs v1.0.1, I ran the unit tests for GoogleCloudPlatform/gcloud-node which were passing on latest node 0.10.x and now a single test is no longer passing.

It appears that when attempting to sign a PEM, during a failure, a SignFinal error is no longer returned. Instead the error message returned is now error:0906D06C:PEM routines:PEM_read_bio:no start line. I've monkey-patched the test here: googleapis/google-cloud-node#346 but this doesn't handle any other sort of SignFinal error.

I looked at the changelog and it gave no indication that this was a breaking change so I'm assuming it was an unintentional change.

@bnoordhuis
Copy link
Member

If you can put together a standalone test case (i.e. a single script that uses only core modules), I or @indutny will take a look. Thanks.

@bnoordhuis bnoordhuis added the crypto Issues and PRs related to the crypto subsystem. label Jan 14, 2015
@ryanseys
Copy link
Contributor Author

Certainly! Here's a standalone test case:

var crypto = require('crypto');
var pem = 'this is a bad key with no start line';

var sign = crypto.createSign('RSA-SHA256');
sign.update('abcdef');  // data
var sig = sign.sign(pem, 'hex');

On io.js v1.0.1 stacktrace:

# ~ $ node crypto-test.js
crypto.js:309
  var ret = this._handle.sign(toBuf(key), null, passphrase);
                         ^
Error: error:0906D06C:PEM routines:PEM_read_bio:no start line
    at Error (native)
    at Sign.sign (crypto.js:309:26)
    at Object.<anonymous> (/Users/ryanseys/crypto-test.js:6:16)
    at Module._compile (module.js:446:26)
    at Object.Module._extensions..js (module.js:464:10)
    at Module.load (module.js:341:32)
    at Function.Module._load (module.js:296:12)
    at Function.Module.runMain (module.js:487:10)
    at startup (node.js:111:16)
    at node.js:809:3

On node 0.10.33 stacktrace:

# ~ $ /usr/local/Cellar/node/0.10.33_1/bin/node crypto-test.js
140735116468992:error:0906D06C:PEM routines:PEM_read_bio:no start line:../deps/openssl/openssl/crypto/pem/pem_lib.c:703:Expecting: ANY PRIVATE KEY

crypto.js:429
  var ret = this._binding.sign(toBuf(key));
                          ^
Error: SignFinal error
    at Sign.sign (crypto.js:429:27)
    at Object.<anonymous> (/Users/ryanseys/crypto-test.js:6:16)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:906:3

@bnoordhuis
Copy link
Member

Thanks, I see what you're saying now. It's an intentional change actually, one that also exists in joyent/node@v0.11 (can't find the commit just now but the change was made sometime last year.)

@ryanseys
Copy link
Contributor Author

Ah, okay. I kinda figured that's what happened. I should have checked with the latest node 0.11.x first. Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crypto Issues and PRs related to the crypto subsystem.
Projects
None yet
2 participants