summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: ead3402)
raw | patch | inline | side by side (parent: ead3402)
author | Thomas Guyot-Sionnest <dermoth@aei.ca> | |
Thu, 19 Mar 2009 02:21:00 +0000 (22:21 -0400) | ||
committer | Thomas Guyot-Sionnest <dermoth@aei.ca> | |
Thu, 19 Mar 2009 05:04:33 +0000 (01:04 -0400) |
plugins/sslutils.c | patch | blob | history | |
plugins/tests/check_http.t | patch | blob | history |
diff --git a/plugins/sslutils.c b/plugins/sslutils.c
index afc24be1f1951c992de2976928eca8b4809547f0..1d4ef94a210683b55bf3cde64a8cc86d50ad1bac 100644 (file)
--- a/plugins/sslutils.c
+++ b/plugins/sslutils.c
#include "common.h"
#include "netutils.h"
-/* Max length of timestamps, ex: "03/05/2009 00:13 GMT". Calculate up to 6
- * chars for the timezone (ex: "GMT-10") and one terminating \0 */
-#define TS_LENGTH 24
-
#ifdef HAVE_SSL
static SSL_CTX *c=NULL;
static SSL *s=NULL;
ASN1_STRING *tm;
int offset;
struct tm stamp;
+ float time_left;
int days_left;
- char timestamp[TS_LENGTH] = "";
+ char timestamp[17] = "";
certificate=SSL_get_peer_certificate(s);
if(! certificate){
stamp.tm_sec = 0;
stamp.tm_isdst = -1;
- float time_left = difftime(timegm(&stamp), time(NULL));
+ time_left = difftime(timegm(&stamp), time(NULL));
days_left = time_left / 86400;
snprintf
- (timestamp, TS_LENGTH, "%02d/%02d/%04d %02d:%02d %s",
+ (timestamp, 17, "%02d/%02d/%04d %02d:%02d",
stamp.tm_mon + 1,
- stamp.tm_mday, stamp.tm_year + 1900, stamp.tm_hour, stamp.tm_min, stamp.tm_zone);
+ stamp.tm_mday, stamp.tm_year + 1900, stamp.tm_hour, stamp.tm_min);
if (days_left > 0 && days_left <= days_till_exp) {
printf (_("WARNING - Certificate expires in %d day(s) (%s).\n"), days_left, timestamp);
index 0a1b0bc89da8fa695c2841d4d0bcf53515c73cb2..d7f4148c32b8105562d911cb4583d1541bb4706b 100755 (executable)
$result = NPTest->testCmd( "$command -p $port_https -S -C 14" );
is( $result->return_code, 0, "$command -p $port_https -S -C 14" );
- is( $result->output, 'OK - Certificate will expire on 03/03/2019 21:41 GMT.', "output ok" );
+ is( $result->output, 'OK - Certificate will expire on 03/03/2019 21:41.', "output ok" );
$result = NPTest->testCmd( "$command -p $port_https -S -C 14000" );
is( $result->return_code, 1, "$command -p $port_https -S -C 14000" );
- like( $result->output, '/WARNING - Certificate expires in \d+ day\(s\) \(03/03/2019 21:41 GMT\)./', "output ok" );
+ like( $result->output, '/WARNING - Certificate expires in \d+ day\(s\) \(03/03/2019 21:41\)./', "output ok" );
# Expired cert tests
$result = NPTest->testCmd( "$command -p $port_https_expired -S -C 7" );
is( $result->return_code, 2, "$command -p $port_https_expired -S -C 7" );
is( $result->output,
- 'CRITICAL - Certificate expired on 03/05/2009 00:13 GMT.',
+ 'CRITICAL - Certificate expired on 03/05/2009 00:13.',
"output ok" );
}