Code

Attempt at detecting 64bit compilation flags between gcc, old, and new versions of...
[nagiosplug.git] / plugins / sslutils.c
index 1d4ef94a210683b55bf3cde64a8cc86d50ad1bac..64f4d61c9179c9c5d93e5ff5e5bebe7a17ac7b98 100644 (file)
@@ -35,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 ();
@@ -48,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;
@@ -65,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) {
@@ -86,7 +97,7 @@ 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;