[英]Sign JWT with public and private key / RSA / Error: error:1E08010C:DECODER routines::unsupported
I want to use 2 RSA keys.我想使用 2 个 RSA 密钥。 Public and private.
公立和私立。 I generate keys here - https://travistidwell.com/jsencrypt/demo/
我在这里生成密钥 - 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?当我尝试签署令牌时,出现错误 - “错误:错误:1E08010C:DECODER routines::unsupported” 我做错了什么?
let access = jwt.sign({role: 'guest'}, process.env.PRIVATE_ACCESS, {algorithm: 'RS256',expiresIn: '1h'})
When you try to access the global env like that, the result will contain new lines aka /n.当您尝试像那样访问全局 env 时,结果将包含换行符 /n。 You should replace the value with
您应该将值替换为
process.env.PRIVATE_ACCESS.replace(/\\n/g, '\n');
and get the original key without new line.并获得没有换行的原始密钥。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.