Created
May 13, 2015 17:50
-
-
Save lgarner/fb4f62b4d7d8fbd51f9f to your computer and use it in GitHub Desktop.
openssl keys and cert generation, signed digest generation, verification of signed digest
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Creating a RSA private key | |
$ openssl genrsa -out rsaprivkey.pem 1024 | |
# Creating a cert file from priv key | |
$ openssl req -new -x509 -key rsaprivkey.pem -out rsacert.pem | |
# Converting from PEM to DER | |
$ openssl x509 -outform der -in rsacert.pem -out rsacert.der | |
# Convertin from DER to PEM | |
$ openssl x509 -inform der -in rsacert.der -out rsacert.pem | |
# Signing a digest of a file | |
$ openssl dgst -sha1 -sign rsaprivkey.pem -out file.sig file | |
# Extracting pub key from cert | |
$ openssl x509 -pubkey -noout -in rsacert.pem > pubkey.pem | |
# Verifyig the signature | |
$ openssl dgst -sha1 -verify pubkey.pem -signature file.sig file | |
# Getting the fingerpring of the cert, from pem cert | |
$ openssl x509 -in rsacert.pem -fingerprint -noout | |
SHA1 Fingerprint=B4:4B:81:58:DA:9A:17:1E:42:54:83:ED:3E:F8:BD:0B:8E:7C:9B:F9 | |
# Getting the fingerprint or the cert, from der (cer) | |
$ openssl dgst -sha1 rsacert.der | |
SHA1(rsacert.der)= b44b8158da9a171e425483ed3ef8bd0b8e7c9bf9 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment