Skip to content

Instantly share code, notes, and snippets.

@btwarog
Forked from pollux-/sha256 hash
Created October 7, 2022 08:05
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 btwarog/d466bd2be6fb66923ee0fad2e2a8e95b to your computer and use it in GitHub Desktop.
Save btwarog/d466bd2be6fb66923ee0fad2e2a8e95b to your computer and use it in GitHub Desktop.
Generating SHA256 hash of a public key from remote server certificate
Creating certificate from remote URL and writing to file (mycertfile.pem)
openssl s_client -showcerts -connect gist.github.com:443 </dev/null 2>/dev/null|openssl x509 -outform PEM >mycertfile.pem
Generating SHA256 hash of public key from a certificate (mycertfile.pem)
openssl x509 -in mycertfile.pem -pubkey -noout | openssl rsa -pubin -outform der | openssl dgst -sha256 -binary | openssl enc -base64
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment