[monitoring-plugins] sslutils: expire time in local timezone format
Jan Wagner
git at monitoring-plugins.org
Mon Jul 21 13:50:07 CEST 2014
Module: monitoring-plugins
Branch: master
Commit: 3bf812beaee7035b1c08e49b55d7962056931d7b
Author: Jan Wagner <waja at cyconet.org>
Date: Tue Oct 1 09:26:41 2013 +0200
URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=3bf812b
sslutils: expire time in local timezone format
sshutils prints the expiry time of certificates in US format
this patch uses the strftime %c, I don't know how portable that is
Thanks to Neil Prockter.
Closes #1188
Closes #1161
Closes #977
Closes #976
Closes #975
Closes #840
Closes #382
---
THANKS.in | 1 +
plugins/sslutils.c | 9 ++++-----
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/THANKS.in b/THANKS.in
index 43ba182..6738ae7 100644
--- a/THANKS.in
+++ b/THANKS.in
@@ -324,3 +324,4 @@ Jean-Claude Computing
Andy Brist
Mikael Falkvidd
Patric Wust
+Neil Prockter
diff --git a/plugins/sslutils.c b/plugins/sslutils.c
index 687bffb..d0ae474 100644
--- a/plugins/sslutils.c
+++ b/plugins/sslutils.c
@@ -153,7 +153,8 @@ int np_net_ssl_check_cert(int days_till_exp_warn, int days_till_exp_crit){
struct tm stamp;
float time_left;
int days_left;
- char timestamp[17] = "";
+ char timestamp[50] = "";
+ time_t tm_t;
certificate=SSL_get_peer_certificate(s);
if (!certificate) {
@@ -211,10 +212,8 @@ int np_net_ssl_check_cert(int days_till_exp_warn, int days_till_exp_crit){
time_left = difftime(timegm(&stamp), time(NULL));
days_left = time_left / 86400;
- snprintf
- (timestamp, 17, "%02d/%02d/%04d %02d:%02d",
- stamp.tm_mon + 1,
- stamp.tm_mday, stamp.tm_year + 1900, stamp.tm_hour, stamp.tm_min);
+ tm_t = mktime (&stamp);
+ strftime(timestamp, 50, "%c", localtime(&tm_t));
if (days_left > 0 && days_left <= days_till_exp_warn) {
printf (_("%s - Certificate '%s' expires in %d day(s) (%s).\n"), (days_left>days_till_exp_crit)?"WARNING":"CRITICAL", cn, days_left, timestamp);
More information about the Commits
mailing list