Skip to content

PEM routines:PEM_read_bio:no start line Error #1

Description

@ailadson
//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?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions