简体   繁体   中英

How to use RSA_PRIVATE_KEY in nodejs for JWT?

I'm following angular documentation https://blog.angular-university.io/angular-jwt-authentication/ in step 2 uses RSA_PRIVATE_KEY but it doesn't explain how to generate it, I have to install something to use

const RSA_PRIVATE_KEY = fs.readFileSync (' ./ demos / private.key ');? 

Thanks

You need OpenSSL binary to generate the keys:

openssl genpkey -out private.pem -aes256 -algorithm rsa -pkeyopt rsa_keygen_bits:4096
openssl pkey -in private.pem -out public.pem -pubout

You're welcome ;)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM