Dave
Dave

Reputation: 4328

Checking the expiry dates of SSL certs

I wrote a script to find the expiry dates of SSL cert in a directory.

shopt -s nullglob
for f in *.0 *.pem *.key *.crt; do
    echo "## CERTIFICATE NAME -> $f ##"
     openssl x509 -noout -in $f   -issuer -subject -dates  
    echo ""
done

Are there any improvements on this?

Upvotes: 4

Views: 9028

Answers (2)

Wajid Shaikh
Wajid Shaikh

Reputation: 439

Please check cmd to get Expected ans :

openssl x509 -noout -text -in abc.cer | grep Not

Output :
        Not Before: Aug 30 10:14:54 2018 GMT
        Not After : Aug 29 10:14:54 2021 GMT

Description : Use your .cer or crt certificate name

Upvotes: 4

Martin v. Löwis
Martin v. Löwis

Reputation: 127457

You shouldn't consider .key files - private keys don't have any expiry dates. Also, depending on your convention, .crt files might be PKCS12 files, in which case you would have to unpack them first.

Not sure why .0 files show up - if they are symlinks, you really should be looking only at the files pointed to. If so, the criterion for selecting files really should be to look at all links, not all .0 files (since there may also be .1 files).

Upvotes: 2

Related Questions