Squoggle

Mac's tech blog

Extract data from a Certificate

Get Info from a Cert:
Using the -text option will give you the full breadth of information:

$ openssl x509 -text -in [cert-file.crt]

This will show a long list of what’s contained in a cert. You can pipe to less if needed.

Extract what cert issued the cert:

$ openssl x509 -noout -in [cert-file.crt] -issuer

Who the certificate was issue to:

$ openssl x509 -noout -in [cert-file.crt] -subject

For what dates is it valid:

$ openssl x509 -noout -in [cert-file.crt] -dates

Expiration date:

$ openssl x509 -noout -in [cert-file.crt] -enddate

Get Serial Number from a Cert:

$ openssl x509 -noout -in [cert-file.crt] -serial

All of the above at once:

$ openssl x509 -noout -in [cert-file.crt] -issuer -subject -dates -serial

Get Signature Algorithm:

$ openssl x509 -text -in [cert-file.crt] | grep 'Signature Algorithm'

Get hash value:

$ openssl x509 -noout -in [cert-file.crt] -hash

Get MD5 fingerprint:

$ openssl x509 -noout -in [cert-file.crt] -fingerprint

Get Modulus of Cert (1024 or 2048):

$ openssl x509 -text -in [cert-file.crt] | grep Modulus

Get SANs from a Cert:

$ openssl x509 -text -in [cert-file.crt] | grep -A 1 Alternative

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.