diff options
author | Peter (pir) Radcliffe <pir-gitweb.com@pir.net> | 2015-11-24 03:03:41 +0000 |
---|---|---|
committer | Sven Nierlein <sven@nierlein.de> | 2016-11-07 22:42:40 +0100 |
commit | a3a78795b2951777d2586abc2ea9ef40ca4f4399 (patch) | |
tree | 4783ca87388d7be860126be9aabac4b05b537ce5 /plugins | |
parent | 7276ce77c7f1dc682b6ac0b58d78445c6bb814bf (diff) | |
download | monitoring-plugins-a3a78795b2951777d2586abc2ea9ef40ca4f4399.tar.gz |
Use GMT timezone in SSL certs
SSL certs are required to use times in GMT per
https://www.ietf.org/rfc/rfc5280.txt but the mktime() here assumes the
current timezone.
Fix the time_t conversion to be done assuming GMT with timegm() and
only do it once rather than twice.
Display the expiry date and time with ISO format years and give an
offset from GMT and a timezone to be very clear about exactly what time
is being displayed. Time given is correct and now in the machine’s
timezone.
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/sslutils.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/plugins/sslutils.c b/plugins/sslutils.c index 4f9c793c..6437289f 100644 --- a/plugins/sslutils.c +++ b/plugins/sslutils.c | |||
@@ -264,10 +264,10 @@ int np_net_ssl_check_cert(int days_till_exp_warn, int days_till_exp_crit){ | |||
264 | (tm->data[10 + offset] - '0') * 10 + (tm->data[11 + offset] - '0'); | 264 | (tm->data[10 + offset] - '0') * 10 + (tm->data[11 + offset] - '0'); |
265 | stamp.tm_isdst = -1; | 265 | stamp.tm_isdst = -1; |
266 | 266 | ||
267 | time_left = difftime(timegm(&stamp), time(NULL)); | 267 | tm_t = timegm(&stamp); |
268 | time_left = difftime(tm_t, time(NULL)); | ||
268 | days_left = time_left / 86400; | 269 | days_left = time_left / 86400; |
269 | tm_t = mktime (&stamp); | 270 | strftime(timestamp, 50, "%F %R %z/%Z", localtime(&tm_t)); |
270 | strftime(timestamp, 50, "%c", localtime(&tm_t)); | ||
271 | 271 | ||
272 | if (days_left > 0 && days_left <= days_till_exp_warn) { | 272 | if (days_left > 0 && days_left <= days_till_exp_warn) { |
273 | printf (_("%s - Certificate '%s' expires in %d day(s) (%s).\n"), (days_left>days_till_exp_crit)?"WARNING":"CRITICAL", cn, days_left, timestamp); | 273 | printf (_("%s - Certificate '%s' expires in %d day(s) (%s).\n"), (days_left>days_till_exp_crit)?"WARNING":"CRITICAL", cn, days_left, timestamp); |