|
|
@@ -30,10 +30,6 @@
|
|
|
#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;
|
|
|
@@ -93,8 +89,9 @@ int np_net_ssl_check_cert(int days_till_exp){
|
|
|
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){
|
|
|
@@ -139,12 +136,12 @@ int np_net_ssl_check_cert(int days_till_exp){
|
|
|
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);
|