January 2019
Intermediate to advanced
798 pages
20h 33m
English
A simpler approach might be passing the threshold to the OpenSSL utilities and letting them determine whether the certificate will be good after that many seconds. A command to check whether the certificate is good for seven days would be as follows:
$ echo | openssl s_client -connect www.google.com:443 2>/dev/null | openssl x509 -checkend 604800 Certificate will not expire
That looks simple enough. If the certificate expires in the given time, the message would say Certificate will expire. The great thing is that the exit code also differs based on the expiry status, so we could return 1 when the certificate is still good and 0 when it expires.
Read now
Unlock full access