Last active
December 12, 2022 23:29
-
-
Save djmetzle/4a5fbb21c2e4d6ecb9f350671b0c1347 to your computer and use it in GitHub Desktop.
Script to fetch and calculate OpenID Connect thumbprint for Github Actions (or others)
This file contains hidden or 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
GITHUB_ACTIONS='token.actions.githubusercontent.com' | |
OIDC_PATH='.well-known/openid-configuration' | |
HOST=$(curl https://$GITHUB_ACTIONS/$OIDC_PATH \ | |
| jq -r '.jwks_uri | split("/")[2]') | |
echo "Fetching thumbprint for: $HOST" | |
RAWCERT=$(echo | openssl s_client -servername $HOST -showcerts -connect $HOST:443 2> /dev/null) | |
CERT=$(echo "$RAWCERT" | sed -n -e '/BEGIN/h' -e '/BEGIN/,/END/H' -e '$x' -e '$p' | tail -n +2) | |
SSLPRINT=$(openssl x509 -fingerprint -noout <<< $CERT) | |
THUMBPRINT=$(echo $SSLPRINT | sed -e "s/.*=//" -e "s/://g" | tr "ABCDEF" "abcdef") | |
echo "thumbprint: $THUMBPRINT" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The arcane version peppered around in various places online does not copy+paste to linux (because of a
tail +2
).This rewrite should accomplish the same thing, calculating the fingerprint, but hopefully names a few of the intermediary steps, to better hint at how the thumbprint is assembled.