Created
September 15, 2021 16:45
-
-
Save liyangau/51bef7735a7da219ced69c6447353f7b to your computer and use it in GitHub Desktop.
Generate DER format RSA and ECC key for JWT CLI to generate JWT token
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
openssl genpkey -algorithm EC \ | |
-pkeyopt ec_paramgen_curve:P-256 \ | |
-pkeyopt ec_param_enc:named_curve | \ | |
openssl pkcs8 -topk8 -nocrypt -outform der > jwt-ecc-private.p8 2>/dev/null && \ | |
openssl pkey -pubout -inform der -outform pem \ | |
-in jwt-ecc-private.p8 \ | |
-out jwt-ecc-public.pem 2>/dev/null && \ | |
openssl genpkey -algorithm RSA \ | |
-pkeyopt rsa_keygen_bits:2048 -outform der > jwt-rsa-private.p8 2>/dev/null && \ | |
openssl pkey -pubout -inform der -outform pem \ | |
-in jwt-rsa-private.p8 \ | |
-out jwt-rsa-public.pem 2>/dev/null && \ | |
echo -e 'Your RSA private key is \033[1;4mjwt-rsa-private.p8\033[0m and RSA public key is \033[1;4mjwt-rsa-public.pem\033[0m' | |
echo -e 'Your ECC private key is \033[1;4mjwt-ecc-private.p8\033[0m and ECC public key is \033[1;4mjwt-ecc-public.pem\033[0m' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment