Reputation: 639
I want to use 2 RSA keys. Public and private. I generate keys here - https://travistidwell.com/jsencrypt/demo/
When I try to sign a token, I get an error - "Error: error:1E08010C:DECODER routines::unsupported" What am I doing wrong?
let access = jwt.sign({role: 'guest'}, process.env.PRIVATE_ACCESS, {algorithm: 'RS256',expiresIn: '1h'})
Upvotes: 0
Views: 4249
Reputation: 2917
When you try to access the global env like that, the result will contain new lines aka /n. You should replace the value with
process.env.PRIVATE_ACCESS.replace(/\\n/g, '\n');
and get the original key without new line.
Upvotes: 2