externalscripts/certificate_expiration-bsd: Certificate expiration check (BSD date(1) variant) as external check (via TCP)
authorTomas Zeman <tzeman@volny.cz>
Fri, 30 Aug 2013 13:20:57 +0200
changeset 30 79eef9a447de
parent 29 3f6120005a40
child 31 50abf2d64158
externalscripts/certificate_expiration-bsd: Certificate expiration check (BSD date(1) variant) as external check (via TCP)
externalscripts/certificate_expiration-bsd
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/externalscripts/certificate_expiration-bsd	Fri Aug 30 13:20:57 2013 +0200
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+echo | openssl s_client  -connect $1:$2 2>/dev/null | \
+sed -n '/-----BEGIN CERTIFICATE-----/,/-----END CERTIFICATE-----/p' | \
+openssl x509 -enddate | grep notAfter| awk -F= '{print $2}' | \
+while read l; do
+	t=`date -j -f "%b %d %T %Y %Z" "$l" +%s`
+	n=`date +%s`
+	echo `expr $t - $n`
+done