Skip to content

Instantly share code, notes, and snippets.

@eheikes
Created September 21, 2020 23:28
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 eheikes/ea6f4361ab89b1017db73259beea9208 to your computer and use it in GitHub Desktop.
Save eheikes/ea6f4361ab89b1017db73259beea9208 to your computer and use it in GitHub Desktop.
openssl cheatsheet
Download from website: openssl s_client -connect online.banno-uat.com:443
Display info about private key: openssl rsa -text -in private-key.pem -noout
Display info about public key: openssl pkey -inform PEM -pubin -in pub.key -text -noout
Display info about cert: openssl x509 [-days 365] -text -in cert.pem -noout
Get public key from cert: openssl x509 -pubkey -noout -in cert.pem > pubkey.pem
Convert from PEM to CER:
openssl x509 -inform PEM -in online.pem -outform DER -out cert.cer
openssl rsa -pubin -inform PEM -in pubkey.pem -outform DER -out pubkey.der
Build cert from keys: openssl req -new -x509 -key privkey.pem -out cacert.pem
Sign file:
openssl dgst -sha1 -sign private-key.pem -out test-data.sha1 test-data.txt && base64 test-data.sha1 > test-data.sha1.txt
Verify signature:
openssl x509 -pubkey -noout -in banno-certificate.pem > banno-certificate.key
openssl dgst -sha1 -verify banno-certificate.key -signature test-data.sha1 test-data.txt
Verify cert matches private key:
openssl x509 –noout –modulus –in test.crt | openssl md5
openssl rsa –noout –modulus –in test.key | openssl md5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment