wiki:openssl_commands
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| wiki:openssl_commands [2021/11/03 10:51] – add Get OCSP stapling info antisa | wiki:openssl_commands [2025/10/16 08:46] (current) – add CSR check command and fix indent antisa | ||
|---|---|---|---|
| Line 2: | Line 2: | ||
| ====== Openssl commands ====== | ====== Openssl commands ====== | ||
| + | ===== Check CSR ===== | ||
| + | openssl req -text -noout -verify -in google.com.csr | ||
| + | | ||
| ===== Get cert expiration date from cert file ===== | ===== Get cert expiration date from cert file ===== | ||
| - | openssl x509 -enddate -noout -in / | + | |
| ===== Verfiy certs ===== | ===== Verfiy certs ===== | ||
| - | openssl verify -CAfile certs/ | + | |
| - | openssl verify -CAfile certs/ | + | |
| ===== Query site for expiration date ===== | ===== Query site for expiration date ===== | ||
| - | echo | openssl s_client -servername example.com -connect example.com: | + | |
| ===== Determine a Key Size from ===== | ===== Determine a Key Size from ===== | ||
| ==== Private Key ==== | ==== Private Key ==== | ||
| Line 36: | Line 38: | ||
| ===== Get cert file from site ===== | ===== Get cert file from site ===== | ||
| - | openssl s_client -connect example.com: | + | openssl s_client -connect example.com: |
| + | |||
| + | <WRAP center round info 60%> | ||
| + | -connect can be the IP address of a server and is not necessarily the same as the -servername. Use -servername when sharing multiple SSL hosts on a single IP address, | ||
| + | </ | ||
| ===== Get OCSP stapling info ===== | ===== Get OCSP stapling info ===== | ||
| Line 42: | Line 48: | ||
| echo QUIT | openssl s_client -servername www.example.com: | echo QUIT | openssl s_client -servername www.example.com: | ||
| + | |||
| + | ===== Check if certificate is valid with private key ===== | ||
| + | If you get an error like | ||
| + | |||
| + | Oct 23 17:55:05 hpb01-rp nginx[2837]: | ||
| + | |||
| + | Check certificate and private key | ||
| + | |||
| + | openssl x509 -in / | ||
| + | |||
| + | openssl rsa -in / | ||
| + | |||
| + | You need to get the same sha sum from both commands. | ||
| + | |||
| + | |||
| + | |||
| + | ===== Additional commands that can be used to inspect Certificates ===== | ||
| + | |||
| + | The openssl x509 utility also allows you to extract specific pieces of information from the certificate file instead of the entire content of a certificate in text. | ||
| + | |||
| + | openssl x509 -in google.com-cert -noout -serial | ||
| + | |||
| + | openssl x509 -in google.com-cert -noout -issuer | ||
| + | |||
| + | openssl x509 -in google.com-cert -noout -dates | ||
| + | |||
| + | openssl x509 -in google.com-cert -noout -subject | ||
| + | |||
| + | openssl x509 -in google.com-cert -noout -pubkey | ||
| + | |||
| + | openssl x509 -in google.com-cert -noout -modulus | ||
| + | |||
| + | openssl x509 -in google.com-cert -noout -ocsp_uri | ||
| + | Note: Last command may not work in all versions of OpenSSL | ||
| + | |||
| + | You can also mix and match arguments from the last step: | ||
| + | |||
| + | openssl x509 -in google.com-cert -noout -subject -issuer | ||
| + | |||
| + | openssl x509 -in google.com-cert -noout -serial -dates | ||
| + | |||
| + | You can also request specific extensions from the certificate: | ||
| + | |||
| + | openssl x509 -in google.com-cert -noout -ext subjectAltName | ||
| + | |||
| + | openssl x509 -in google.com-cert -noout -ext basicConstraints | ||
| + | |||
| + | openssl x509 -in google.com-cert -noout -ext crlDistributionPoints | ||
| + | |||
| + | openssl x509 -in google.com-cert -noout -ext keyUsage | ||
| + | |||
| + | openssl x509 -in google.com-cert -noout -ext extendedKeyUsage | ||
| + | |||
| + | openssl x509 -in google.com-cert -noout -ext authorityInfoAccess | ||
| + | |||
| + | openssl x509 -in google.com-cert -noout -ext subjectKeyIdentifier | ||
| + | |||
| + | openssl x509 -in google.com-cert -noout -ext authorityKeyIdentifier | ||
| + | |||
| + | |||
| + | ====== See also ====== | ||
| + | * [[wiki: | ||
| + | |||
| + | ====== References ====== | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
wiki/openssl_commands.1635936687.txt.gz · Last modified: by antisa
