Skip to content

Instantly share code, notes, and snippets.

@phi1ipp
Last active June 22, 2023 17:33
Show Gist options
  • Save phi1ipp/2b0985b2f39bd7ff341843d03e994e98 to your computer and use it in GitHub Desktop.
Save phi1ipp/2b0985b2f39bd7ff341843d03e994e98 to your computer and use it in GitHub Desktop.
Converting RSA PEM to JWK
# 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