Skip to content

Instantly share code, notes, and snippets.

@ppdouble
Last active June 9, 2023 00:04
Show Gist options
  • Save ppdouble/bc12355dde9e815c77c4d8785b0df045 to your computer and use it in GitHub Desktop.
Save ppdouble/bc12355dde9e815c77c4d8785b0df045 to your computer and use it in GitHub Desktop.
generate 2048 bits rsa public private key pair for jwt token
jwtkey=/home/jwt/sign/keys
mkdir -p $jwtkey
openssl genrsa -out $jwtkey/rsa-prv.pem 2048
openssl rsa -in $jwtkey/rsa-prv.pem -pubout > $jwtkey/rsa-pub.pem
# OpenSSL `1.0.2k-fips on 26 Jan 2017` on `CentOS Linux release 7.9.2009 (Core)` gives pkcs#1 with -----BEGIN RSA PRIVATE KEY-----
# OpenSSL `3.0.8 7 Feb 2023 (Library: OpenSSL 3.0.8 7 Feb 2023)` on `Fedora release 38 (Thirty Eight)` gives pkcs#8 with -----BEGIN PRIVATE KEY-----
@ppdouble
Copy link
Author

ppdouble commented Jun 8, 2023

https://gist.github.com/nghiaht/224f7fe04ea591c6d2fddbee6c173379

openssl genpkey -algorithm RSA -out private.pem -pkeyopt rsa_keygen_bits:2048
openssl rsa -pubout -in private.pem -out public_key.pem

The commands give pkcs#8 both with openssl 1.0.2 and openssl 3.0.8.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment