iorireda3
iorireda3

Reputation: 43

How to determine SSL cert expiration date from a PEM which have a lot of certificats concatenated on one file (pem)?

How to determine SSL cert expiration date from a PEM which have a lot of certificats concatenated on one file (pem) ?

Example:

# cat cert.pem

-----BEGIN CERTIFICATE----- 

... 

-----END CERTIFICATE----- 

-----BEGIN CERTIFICATE----- 

... 

-----END CERTIFICATE-----

The command below, give me only the end date of the first certificate on the file

# openssl x509 -in cert.pem -noout -enddate
notAfter=Sep 26 16:12:59 2019 GMT

Have you any idea to get end date of all certificates (one by one) using shell?

Upvotes: 4

Views: 11286

Answers (1)

Patrick Mevzek
Patrick Mevzek

Reputation: 12515

As found out in https://serverfault.com/questions/391396/how-to-split-a-pem-file#676968 something like that works:

openssl crl2pkcs7 -nocrl -certfile cert.pem | openssl pkcs7 -print_certs -text | grep -E '(Subject:|Not After)'

But the subject comes after the date.

Otherwise you need to do some shell glue using sed, awk or perl for example.

Upvotes: 5

Related Questions