Last active
June 22, 2023 17:33
-
-
Save phi1ipp/2b0985b2f39bd7ff341843d03e994e98 to your computer and use it in GitHub Desktop.
Converting RSA PEM to JWK
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
# generate RSA | |
openssl genrsa 4096 > priv.pem | |
openssl rsa -in priv.pem -pubout > pub.pem | |
# encode modulus | |
n=$(openssl rsa -pubin -in pub.pem -noout -modulus | cut -f2 -d= | xxd -r -p | base64 | sed -e 's/\//_/g' -e 's/+/-/g' -e 's/=//g') | |
# encode exponent | |
# standard one is 65537 | |
e="AQAB" | |
kty="RSA" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment