Skip to content

Instantly share code, notes, and snippets.

@aeris
Created January 17, 2016 21:18
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save aeris/d3fc10b9775419f5be88 to your computer and use it in GitHub Desktop.
Generate HPKP or TLSA fingerprint
#!/bin/bash
case "$1" in
hpkp)
case "$2" in
key)
openssl rsa -in "$3" -outform der -pubout 2>/dev/null | openssl dgst -sha256 -binary | openssl enc -base64
;;
csr)
openssl req -in "$3" -pubkey -noout | openssl rsa -pubin -outform der 2>/dev/null | openssl dgst -sha256 -binary | openssl enc -base64
;;
crt)
openssl x509 -in "$3" -pubkey -noout | openssl rsa -pubin -outform der 2>/dev/null | openssl dgst -sha256 -binary | openssl enc -base64
;;
esac
;;
tlsa)
case "$2" in
key)
openssl rsa -in "$3" -outform der -pubout 2>/dev/null | openssl dgst -sha512 -hex
;;
csr)
openssl req -in "$3" -pubkey -noout | openssl rsa -pubin -outform der 2>/dev/null | openssl dgst -sha512 -hex
;;
crt)
openssl x509 -in "$3" -pubkey -noout | openssl rsa -pubin -outform der 2>/dev/null | openssl dgst -sha512 -hex
;;
esac
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment