diff -urN ../ndoutils-1.4b7/include/common.h ./include/common.h --- ../ndoutils-1.4b7/include/common.h 2007-01-08 01:35:54.000000000 +0100 +++ ./include/common.h 2008-11-06 12:24:14.000000000 +0100 @@ -18,4 +18,16 @@ #define NDO_OK 0 +#define HAVE_SSL 1 +#ifdef HAVE_SSL +#include +#include +#include +#include +#include +#include +#include +#endif + + #endif diff -urN ../ndoutils-1.4b7/include/dh.h ./include/dh.h --- ../ndoutils-1.4b7/include/dh.h 1970-01-01 01:00:00.000000000 +0100 +++ ./include/dh.h 2008-11-06 10:59:56.000000000 +0100 @@ -0,0 +1,26 @@ +#ifndef HEADER_DH_H +#define HEADER_DH_H 1 +#include +#endif +DH *get_dh512() + { + static unsigned char dh512_p[]={ + 0xDF,0x28,0x54,0x54,0x42,0x96,0x87,0x0D,0x67,0x9D,0xCA,0x57, + 0x53,0xF2,0x05,0x3A,0xE9,0x7E,0x7A,0xC3,0x00,0x3B,0x80,0x90, + 0xBA,0x0E,0x8D,0xE1,0x1E,0x8A,0x30,0x9A,0x6B,0x26,0x7C,0x55, + 0x70,0x82,0x7B,0x30,0xE5,0x1D,0x83,0x4B,0xB2,0x9B,0xE8,0xAA, + 0xFA,0x41,0x72,0x14,0xF4,0x23,0x29,0x03,0xDB,0x8D,0xCF,0x3C, + 0x79,0xE0,0x5F,0x13, + }; + static unsigned char dh512_g[]={ + 0x02, + }; + DH *dh; + + if ((dh=DH_new()) == NULL) return(NULL); + dh->p=BN_bin2bn(dh512_p,sizeof(dh512_p),NULL); + dh->g=BN_bin2bn(dh512_g,sizeof(dh512_g),NULL); + if ((dh->p == NULL) || (dh->g == NULL)) + { DH_free(dh); return(NULL); } + return(dh); + } diff -urN ../ndoutils-1.4b7/include/io.h ./include/io.h --- ../ndoutils-1.4b7/include/io.h 2007-01-08 01:35:54.000000000 +0100 +++ ./include/io.h 2008-11-06 16:20:24.000000000 +0100 @@ -47,4 +47,5 @@ char *ndo_escape_buffer(char *); char *ndo_unescape_buffer(char *); + #endif diff -urN ../ndoutils-1.4b7/src/io.c ./src/io.c --- ../ndoutils-1.4b7/src/io.c 2007-01-08 01:35:50.000000000 +0100 +++ ./src/io.c 2008-11-06 16:28:30.000000000 +0100 @@ -12,6 +12,16 @@ #include "../include/io.h" +#ifdef HAVE_SSL +SSL_METHOD *meth; +SSL_CTX *ctx; +SSL *ssl; +int use_ssl=NDO_TRUE; +#else +int use_ssl=NDO_FALSE; +#endif + + /**************************************************************/ @@ -140,6 +150,7 @@ struct hostent *hp=NULL; mode_t mode=S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP; int newfd=0; + int rc; /* use file */ if(type==NDO_SINK_FILE){ @@ -178,6 +189,22 @@ /* we are sending output to a TCP socket */ else if(type==NDO_SINK_TCPSOCKET){ +#ifdef HAVE_SSL + if(use_ssl==NDO_TRUE){ + SSL_library_init(); + SSLeay_add_ssl_algorithms(); + meth=SSLv23_client_method(); + SSL_load_error_strings(); + if((ctx=SSL_CTX_new(meth))==NULL){ + printf("CHECK_NRPE: Error - could not create SSL context.\n"); + return NDO_ERROR; + } + /* ADDED 01/19/2004 */ + /* use only TLSv1 protocol */ + SSL_CTX_set_options(ctx,SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3); + } +#endif + if(name==NULL) return NDO_ERROR; @@ -208,7 +235,24 @@ close(newfd); return NDO_ERROR; } - } +#ifdef HAVE_SSL + if(use_ssl==NDO_TRUE){ + if((ssl=SSL_new(ctx))!=NULL){ + SSL_CTX_set_cipher_list(ctx,"ADH"); + SSL_set_fd(ssl,newfd); + if((rc=SSL_connect(ssl))!=1){ + printf("Error - Could not complete SSL handshake.\n"); + SSL_CTX_free(ctx); + close(newfd); + return NDO_ERROR; + } + }else{ + printf("CHECK_NRPE: Error - Could not create SSL connection structure.\n"); + return NDO_ERROR; + } + } +#endif + } /* unknown sink type */ else @@ -234,8 +278,13 @@ while(tbytes