From 0b6423f9c99d9edf8c96fefd0f6c453859395aa1 Mon Sep 17 00:00:00 2001 From: Holger Weiss Date: Mon, 30 Sep 2013 00:03:24 +0200 Subject: Import Nagios Plugins site Import the Nagios Plugins web site, Cronjobs, infrastructure scripts, and configuration files. --- .../431216-check_http-dateformat-subjectname.diff | 71 ++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 web/attachments/431216-check_http-dateformat-subjectname.diff (limited to 'web/attachments/431216-check_http-dateformat-subjectname.diff') diff --git a/web/attachments/431216-check_http-dateformat-subjectname.diff b/web/attachments/431216-check_http-dateformat-subjectname.diff new file mode 100644 index 0000000..28592c1 --- /dev/null +++ b/web/attachments/431216-check_http-dateformat-subjectname.diff @@ -0,0 +1,71 @@ +diff -u -p nagios-plugins-1.4.15/plugins/sslutils.c.v0 nagios-plugins-1.4.15/plugins/sslutils.c +--- nagios-plugins-1.4.15/plugins/sslutils.c.v0 2011-12-19 17:42:22.000000000 +0100 ++++ nagios-plugins-1.4.15/plugins/sslutils.c 2011-12-19 17:57:14.000000000 +0100 +@@ -103,6 +103,7 @@ int np_net_ssl_check_cert(int days_till_ + float time_left; + int days_left; + char timestamp[17] = ""; ++ char subject[256]; + + certificate=SSL_get_peer_certificate(s); + if(! certificate){ +@@ -113,10 +114,14 @@ int np_net_ssl_check_cert(int days_till_ + /* Retrieve timestamp of certificate */ + tm = X509_get_notAfter (certificate); + ++ /* Retrieve subject name in certificate. */ ++ *subject = '\0'; ++ X509_NAME_get_text_by_NID(X509_get_subject_name(certificate), NID_commonName, subject, 256); ++ + /* Generate tm structure to process timestamp */ + if (tm->type == V_ASN1_UTCTIME) { + if (tm->length < 10) { +- printf ("%s\n", _("CRITICAL - Wrong time format in certificate.")); ++ printf ("%s\n", _("CRITICAL - Wrong time format in certificate %s."), subject); + return STATE_CRITICAL; + } else { + stamp.tm_year = (tm->data[0] - '0') * 10 + (tm->data[1] - '0'); +@@ -126,7 +131,7 @@ int np_net_ssl_check_cert(int days_till_ + } + } else { + if (tm->length < 12) { +- printf ("%s\n", _("CRITICAL - Wrong time format in certificate.")); ++ printf ("%s\n", _("CRITICAL - Wrong time format in certificate %s."), subject); + return STATE_CRITICAL; + } else { + stamp.tm_year = +@@ -149,23 +154,30 @@ int np_net_ssl_check_cert(int days_till_ + + time_left = difftime(timegm(&stamp), time(NULL)); + days_left = time_left / 86400; ++#ifdef AMERICAN_DATE_FORMAT + 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); ++#else ++ snprintf ++ (timestamp, 17, "%04d-%02d-%02d %02d:%02d", ++ stamp.tm_year + 1900, ++ stamp.tm_mon + 1, stamp.tm_mday, stamp.tm_hour, stamp.tm_min); ++#endif + + if (days_left > 0 && days_left <= days_till_exp) { +- printf (_("WARNING - Certificate expires in %d day(s) (%s).\n"), days_left, timestamp); ++ printf (_("WARNING - Certificate %s expires in %d day(s) (%s).\n"), subject, days_left, timestamp); + return STATE_WARNING; + } else if (time_left < 0) { +- printf (_("CRITICAL - Certificate expired on %s.\n"), timestamp); ++ printf (_("CRITICAL - Certificate %s expired on %s.\n"), subject, timestamp); + return STATE_CRITICAL; + } else if (days_left == 0) { +- printf (_("WARNING - Certificate expires today (%s).\n"), timestamp); ++ printf (_("WARNING - Certificate %s expires today (%s).\n"), subject, timestamp); + return STATE_WARNING; + } + +- printf (_("OK - Certificate will expire on %s.\n"), timestamp); ++ printf (_("OK - Certificate %s will expire on %s.\n"), subject, timestamp); + X509_free (certificate); + return STATE_OK; + # else /* ifndef USE_OPENSSL */ -- cgit v1.2.3-74-g34f1