OpenSSL cheatsheet based on https://httpd.apache.org/docs/2.0/ssl/ssl_faq.html.
openssl req -x509 -newkey rsa:4096 -sha256 -days 3650 -nodes \
-keyout server.key -out server.crt -subj "/CN=example.com" \
-addext "subjectAltName=DNS:example.com,DNS:www.example.net,IP:10.0.0.1"
Certificate
openssl x509 -noout -text -in server.crt
Key
openssl rsa -noout -text -in server.key
start and end
openssl x509 -noout -dates -in server.crt
start only
openssl x509 -noout -startdate -in server.crt
end only
openssl x509 -noout -enddate -in server.crt
openssl x509 -checkend 86400 -noout -in server.crt
The 'modulus' and the 'public exponent' portions in the key and the Certificate must match. As the public exponent is usually 65537 and it's difficult to visually check that the long modulus numbers are the same, you can use the following approach:
openssl x509 -noout -modulus -in server.crt | openssl md5 && \
openssl rsa -noout -modulus -in server.key | openssl md5
A simple way to compare two 'modulus' (If more than one hash is displayed, they don't match):
(openssl x509 -noout -modulus -in server.pem | openssl md5; openssl rsa -noout -modulus -in server.key | openssl md5) | uniq
openssl req -noout -modulus -in server.csr | openssl md5
openssl s_client -connect your_host.domain.com:443 | openssl x509 -noout -text