Skip to content

Instantly share code, notes, and snippets.

@haryx8
Created July 13, 2019 00:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save haryx8/dddf713977589ccc9f96d06b177bfebc to your computer and use it in GitHub Desktop.
Save haryx8/dddf713977589ccc9f96d06b177bfebc to your computer and use it in GitHub Desktop.
#!/bin/bash
PIN1=`openssl x509 -pubkey < primary.crt | openssl pkey -pubin -outform der | openssl dgst -sha256 -binary | base64`
PIN2=`openssl x509 -pubkey < backup.crt | openssl pkey -pubin -outform der | openssl dgst -sha256 -binary | base64`
echo
echo ==================================
echo == Public_Key_Pinning generator ==
echo ==================================
echo
echo -e "\033[5m\033[1m\033[31mapache:\033[0m"
echo Header always set Public-Key-Pins "pin-sha256=\"$PIN1\"; pin-sha256=\"$PIN2\"; max-age=5184000; includeSubDomains"
echo
echo -e "\033[5m\033[1m\033[92mnginx:\033[0m"
echo "add_header Public-Key-Pins 'pin-sha256=\"$PIN1\"; pin-sha256=\"$PIN2\"; max-age=5184000; includeSubDomains' always;"
echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment