diff options
Diffstat (limited to 'plugins/sslutils.c')
| -rw-r--r-- | plugins/sslutils.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/plugins/sslutils.c b/plugins/sslutils.c index 4f9c793c..b412ef3d 100644 --- a/plugins/sslutils.c +++ b/plugins/sslutils.c | |||
| @@ -197,6 +197,7 @@ int np_net_ssl_check_cert(int days_till_exp_warn, int days_till_exp_crit){ | |||
| 197 | X509_NAME *subj=NULL; | 197 | X509_NAME *subj=NULL; |
| 198 | char timestamp[50] = ""; | 198 | char timestamp[50] = ""; |
| 199 | char cn[MAX_CN_LENGTH]= ""; | 199 | char cn[MAX_CN_LENGTH]= ""; |
| 200 | char *tz; | ||
| 200 | 201 | ||
| 201 | int cnlen =-1; | 202 | int cnlen =-1; |
| 202 | int status=STATE_UNKNOWN; | 203 | int status=STATE_UNKNOWN; |
| @@ -264,10 +265,18 @@ 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'); | 265 | (tm->data[10 + offset] - '0') * 10 + (tm->data[11 + offset] - '0'); |
| 265 | stamp.tm_isdst = -1; | 266 | stamp.tm_isdst = -1; |
| 266 | 267 | ||
| 267 | time_left = difftime(timegm(&stamp), time(NULL)); | 268 | tm_t = timegm(&stamp); |
| 269 | time_left = difftime(tm_t, time(NULL)); | ||
| 268 | days_left = time_left / 86400; | 270 | days_left = time_left / 86400; |
| 269 | tm_t = mktime (&stamp); | 271 | tz = getenv("TZ"); |
| 270 | strftime(timestamp, 50, "%c", localtime(&tm_t)); | 272 | setenv("TZ", "GMT", 1); |
| 273 | tzset(); | ||
| 274 | strftime(timestamp, 50, "%c %z", localtime(&tm_t)); | ||
| 275 | if (tz) | ||
| 276 | setenv("TZ", tz, 1); | ||
| 277 | else | ||
| 278 | unsetenv("TZ"); | ||
| 279 | tzset(); | ||
| 271 | 280 | ||
| 272 | if (days_left > 0 && days_left <= days_till_exp_warn) { | 281 | 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); | 282 | printf (_("%s - Certificate '%s' expires in %d day(s) (%s).\n"), (days_left>days_till_exp_crit)?"WARNING":"CRITICAL", cn, days_left, timestamp); |
