Last active
September 29, 2022 11:12
-
-
Save jkroepke/0b6edb588aa6dcff5b392e7350359e21 to your computer and use it in GitHub Desktop.
JWKS to PEM in bash
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
#!/usr/bin/env sh | |
set -euo pipefail | |
JWKS_TEMP=$(mktemp) | |
JWKS_URL=$1 | |
curl -s "${JWKS_URL}" | \ | |
python -c 'import sys, json; data=json.load(sys.stdin); print(data["keys"][0]["n"] + data["keys"][0]["e"])' > "${JWKS_TEMP}" | |
{ | |
echo 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA' | openssl base64 -d; | |
head -c 256 "${JWKS_TEMP}"; | |
printf '\2\3'; | |
tail -c+258 "${JWKS_TEMP}" | head -c 3 | |
} | openssl pkey -inform der -outform pem -pubin |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
doesn't work for me
i got different result then here https://8gwifi.org/jwkconvertfunctions.jsp