Skip to content

Instantly share code, notes, and snippets.

@AdamWorley
Last active August 25, 2020 12:07
Show Gist options
  • Save AdamWorley/92ae16b8dc09db78691625527434e51e to your computer and use it in GitHub Desktop.
Save AdamWorley/92ae16b8dc09db78691625527434e51e to your computer and use it in GitHub Desktop.
#!/bin/bash
echo "----------------------------------------------"
echo " Generate Self Signed Cert"
echo "----------------------------------------------"
name="clientCert"
echo "Generating certificate $name.crt"
openssl req -x509 -newkey rsa:4096 -sha256 -days 2190 -nodes -keyout $name.key -out $name.crt -subj "/CN=$name"
echo "Creating $name.pfx"
openssl pkcs12 -export -in $name.crt -inkey $name.key -out $name.pfx
echo "Creating $name.json"
base64Thumbprint=$(sha256sum $name.crt)
keyid=$(uuidgen)
base64Value=$(base64 "$name.crt")
printf '{"customKeyIdentifier": "%s", "keyId": "%s", "type": "AsymmetricX509Cert", "usage": "Verify", "value": "%s"}' "$base64Thumbprint" "$keyid" "$base64Value" > $name.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment