OpenSSL Cheat Sheat
By Roman Pertl
I know I know, there are plenty of openssl cheat sheets out there already (1 or 2). But as I keep using googling it again and again to find the most useful openssl commands I decided to do my own – the first version of the blog entries is already 3 years old actually. Another reason for creating the list is that I remember things better when I am writing the down.
Show contents of a certificate
openssl x509 -fingerprint -sha256 -noout -text -in domain.com.crt
Show contents of a certificate request (CSR)
openssl req -text -noout -verify -in CSR.csr
OpenSSL HTTPS Client with SNI
see 3
openssl s_client -connect roman.pertl.name:443 -servername roman.pertl.name
Generate a CSR to send to an external CA
openssl req -new -newkey rsa:2048 -sha256 -nodes -out roman.pertl.org.csr -keyout roman.pertl.org.key -subj "/C=US/ST=NY/L=NY/O=Roman Pertl/OU=Hostmaster/CN=roman.pertl.org"
Generate a Self-Signed SSL Certificate
openssl req -x509 -nodes -days 365 -newkey rsa:4096 -sha256 -keyout pertl.org.key -out pertl.org.crt -subj "/C=AT/ST=Korneuburg/L=Korneuburg/O=Pertl/OU=Hostmaster/CN=*.pertl.org"
Newer versions of browsers e.g. Chrome require to set the DNS alt attribute additional of the CN field (4 and 5).
openssl req -x509 -nodes -days 365 -newkey rsa:4096 -sha256 -reqexts SAN -extensions SAN -config <(cat /System/Library/OpenSSL/openssl.cnf <(printf '[SAN]\nsubjectAltName=DNS:*.pertl.org')) -keyout pertl.org.key -out pertl.org.crt -subj "/C=AT/ST=Korneuburg/L=Korneuburg/O=Pertl/OU=Hostmaster/CN=*.pertl.org"
Generate a Self-Signed CA Root Certificate
openssl req -nodes -newkey rsa:4096 -x509 -sha256 -days 3650 -keyout rootCA.key -reqexts v3_req -extensions v3_ca -out rootCA.crt -subj "/C=AT/ST=Korneuburg/L=Korneuburg/O=Pertl/OU=Hostmaster/CN=pertl CA"
Generate custom dh param file
openssl dhparam -out domain.at.dhparam 4096
Links
- SSL Shopper most common openssl commands
- stanzgy - openssl self signed cert cheatsheet
- Major - Using openssl s_client Command
- Serverfault - Generating self signed certs for Chrome
- deliciousbrains - using https locally