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

PEM routines:PEM_read_bio:no start line Error #1

Open
ailadson opened this issue Jun 14, 2018 · 1 comment
Open

PEM routines:PEM_read_bio:no start line Error #1

ailadson opened this issue Jun 14, 2018 · 1 comment

Comments

@ailadson
Copy link

//server.js

const nodeJWT = require('node-jwk');
const njwt = require('njwt');

app.get('/cypress-auth', (req, res) => {
  const config = JSON.parse(fs.readFileSync(process.env.CYPRESS_CONFIG_FILEPATH, 'utf8'));
  const keySet = nodeJWT.JWKSet.fromObject(config.keySet);
  const jwk = keySet.findKeyById(config.kid);
  // console.log(keySet)
  const keyPEM = jwk.key.toPublicKeyPEM();
  const jwt = njwt.create(config.claims, keyPEM, jwk.alg);
  res.json({ access_token: jwt.compact() });
});

My keySet objects have the following fields:

  • "alg"
  • "kty"
  • "use"
  • "x5c"
  • "n"
  • "e"
  • "kid"
  • "x5t"

I get the following error:

Error: error:0906D06C:PEM routines:PEM_read_bio:no start line
    at Sign.sign (internal/crypto/sig.js:85:26)
    at Jwt.sign (/Users/.../project_root/node_modules/njwt/index.js:228:63)
    at Jwt.compact (/Users/.../project_root/node_modules/njwt/index.js:250:29)

Any ideas?

@HyperBrain
Copy link
Owner

@ailadson it seems that njwt somehow has trouble reading the PEM. Can you dump the pem and check it with OpenSSL directly? Maybe you get something that hints to the issue?

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