Imported Upstream version 1.4.13+git200906171200
This commit is contained in:
parent
4ab9f0d24c
commit
d0b8ab8112
362 changed files with 34110 additions and 10773 deletions
|
@ -5,8 +5,6 @@
|
|||
* License: GPL
|
||||
* Copyright (c) 2005-2007 Nagios Plugins Development Team
|
||||
*
|
||||
* Last Modified: $Date: 2008-01-31 11:27:22 +0000 (Thu, 31 Jan 2008) $
|
||||
*
|
||||
* Description:
|
||||
*
|
||||
* This file contains common functions for plugins that require SSL.
|
||||
|
@ -25,7 +23,6 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* $Id: sslutils.c 1918 2008-01-31 11:27:22Z dermoth $
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
|
@ -38,7 +35,11 @@ static SSL_CTX *c=NULL;
|
|||
static SSL *s=NULL;
|
||||
static int initialized=0;
|
||||
|
||||
int np_net_ssl_init (int sd){
|
||||
int np_net_ssl_init (int sd) {
|
||||
return np_net_ssl_init_with_hostname(sd, NULL);
|
||||
}
|
||||
|
||||
int np_net_ssl_init_with_hostname (int sd, char *host_name) {
|
||||
if (!initialized) {
|
||||
/* Initialize SSL context */
|
||||
SSLeay_add_ssl_algorithms ();
|
||||
|
@ -51,6 +52,10 @@ int np_net_ssl_init (int sd){
|
|||
return STATE_CRITICAL;
|
||||
}
|
||||
if ((s = SSL_new (c)) != NULL){
|
||||
#ifdef SSL_set_tlsext_host_name
|
||||
if (host_name != NULL)
|
||||
SSL_set_tlsext_host_name(s, host_name);
|
||||
#endif
|
||||
SSL_set_fd (s, sd);
|
||||
if (SSL_connect(s) == 1){
|
||||
return OK;
|
||||
|
@ -68,6 +73,9 @@ int np_net_ssl_init (int sd){
|
|||
|
||||
void np_net_ssl_cleanup (){
|
||||
if(s){
|
||||
#ifdef SSL_set_tlsext_host_name
|
||||
SSL_set_tlsext_host_name(s, NULL);
|
||||
#endif
|
||||
SSL_shutdown (s);
|
||||
SSL_free (s);
|
||||
if(c) {
|
||||
|
@ -89,9 +97,10 @@ int np_net_ssl_read(void *buf, int num){
|
|||
int np_net_ssl_check_cert(int days_till_exp){
|
||||
# ifdef USE_OPENSSL
|
||||
X509 *certificate=NULL;
|
||||
ASN1_STRING *tm;
|
||||
ASN1_STRING *tm;
|
||||
int offset;
|
||||
struct tm stamp;
|
||||
float time_left;
|
||||
int days_left;
|
||||
char timestamp[17] = "";
|
||||
|
||||
|
@ -138,7 +147,8 @@ int np_net_ssl_check_cert(int days_till_exp){
|
|||
stamp.tm_sec = 0;
|
||||
stamp.tm_isdst = -1;
|
||||
|
||||
days_left = (mktime (&stamp) - time (NULL)) / 86400;
|
||||
time_left = difftime(timegm(&stamp), time(NULL));
|
||||
days_left = time_left / 86400;
|
||||
snprintf
|
||||
(timestamp, 17, "%02d/%02d/%04d %02d:%02d",
|
||||
stamp.tm_mon + 1,
|
||||
|
@ -147,7 +157,7 @@ int np_net_ssl_check_cert(int days_till_exp){
|
|||
if (days_left > 0 && days_left <= days_till_exp) {
|
||||
printf (_("WARNING - Certificate expires in %d day(s) (%s).\n"), days_left, timestamp);
|
||||
return STATE_WARNING;
|
||||
} else if (days_left < 0) {
|
||||
} else if (time_left < 0) {
|
||||
printf (_("CRITICAL - Certificate expired on %s.\n"), timestamp);
|
||||
return STATE_CRITICAL;
|
||||
} else if (days_left == 0) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue