Roman
Roman

Reputation: 639

Sign JWT with public and private key / RSA / Error: error:1E08010C:DECODER routines::unsupported

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

Answers (1)

Vlad B.
Vlad B.

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

Related Questions