summaryrefslogtreecommitdiffstats
path: root/plugins/sslutils.c
diff options
context:
space:
mode:
authorThomas Guyot-Sionnest <dermoth@aei.ca>2009-03-18 22:21:00 -0400
committerThomas Guyot-Sionnest <dermoth@aei.ca>2009-03-19 01:04:33 -0400
commit37e432ec776cda34e0e410fe5c75eb3b4871f74c (patch)
treebcf99b0af8c4ddd4a052e40006936a616954f877 /plugins/sslutils.c
parentead340235ef352674a0033633dc913be5efc292b (diff)
downloadmonitoring-plugins-37e432ec776cda34e0e410fe5c75eb3b4871f74c.tar.gz
Revert "Add timezone support and fix checks around cert expiration" (keep the expiration fix)
This reverts commit d41a33a434558189300113c28b26e2d3d681d390.
Diffstat (limited to 'plugins/sslutils.c')
-rw-r--r--plugins/sslutils.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/plugins/sslutils.c b/plugins/sslutils.c
index afc24be1..1d4ef94a 100644
--- a/plugins/sslutils.c
+++ b/plugins/sslutils.c
@@ -30,10 +30,6 @@
30#include "common.h" 30#include "common.h"
31#include "netutils.h" 31#include "netutils.h"
32 32
33/* Max length of timestamps, ex: "03/05/2009 00:13 GMT". Calculate up to 6
34 * chars for the timezone (ex: "GMT-10") and one terminating \0 */
35#define TS_LENGTH 24
36
37#ifdef HAVE_SSL 33#ifdef HAVE_SSL
38static SSL_CTX *c=NULL; 34static SSL_CTX *c=NULL;
39static SSL *s=NULL; 35static SSL *s=NULL;
@@ -93,8 +89,9 @@ int np_net_ssl_check_cert(int days_till_exp){
93 ASN1_STRING *tm; 89 ASN1_STRING *tm;
94 int offset; 90 int offset;
95 struct tm stamp; 91 struct tm stamp;
92 float time_left;
96 int days_left; 93 int days_left;
97 char timestamp[TS_LENGTH] = ""; 94 char timestamp[17] = "";
98 95
99 certificate=SSL_get_peer_certificate(s); 96 certificate=SSL_get_peer_certificate(s);
100 if(! certificate){ 97 if(! certificate){
@@ -139,12 +136,12 @@ int np_net_ssl_check_cert(int days_till_exp){
139 stamp.tm_sec = 0; 136 stamp.tm_sec = 0;
140 stamp.tm_isdst = -1; 137 stamp.tm_isdst = -1;
141 138
142 float time_left = difftime(timegm(&stamp), time(NULL)); 139 time_left = difftime(timegm(&stamp), time(NULL));
143 days_left = time_left / 86400; 140 days_left = time_left / 86400;
144 snprintf 141 snprintf
145 (timestamp, TS_LENGTH, "%02d/%02d/%04d %02d:%02d %s", 142 (timestamp, 17, "%02d/%02d/%04d %02d:%02d",
146 stamp.tm_mon + 1, 143 stamp.tm_mon + 1,
147 stamp.tm_mday, stamp.tm_year + 1900, stamp.tm_hour, stamp.tm_min, stamp.tm_zone); 144 stamp.tm_mday, stamp.tm_year + 1900, stamp.tm_hour, stamp.tm_min);
148 145
149 if (days_left > 0 && days_left <= days_till_exp) { 146 if (days_left > 0 && days_left <= days_till_exp) {
150 printf (_("WARNING - Certificate expires in %d day(s) (%s).\n"), days_left, timestamp); 147 printf (_("WARNING - Certificate expires in %d day(s) (%s).\n"), days_left, timestamp);