summaryrefslogtreecommitdiffstats
path: root/web/attachments/388024-sslutils.patch
blob: 417c6be6d49bbd3de200efabfd3994335c814011 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
--- plugins/sslutils.c	2010-07-27 16:47:16.000000000 -0400
+++ sslutils.c	2010-09-27 10:16:20.000000000 -0400
@@ -51,24 +51,40 @@
 				printf ("%s\n", _("CRITICAL - Cannot create SSL context."));
 				return STATE_CRITICAL;
 		}
-		if ((s = SSL_new (c)) != NULL){
+		if ((s = SSL_new (c)) == NULL){
+			printf ("%s\n", _("CRITICAL - Cannot initiate SSL handshake."));
+		    return STATE_CRITICAL;
+		}
 #ifdef SSL_set_tlsext_host_name
-				if (host_name != NULL)
-					SSL_set_tlsext_host_name(s, 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;
-				} else {
-						printf ("%s\n", _("CRITICAL - Cannot make SSL connection "));
-#  ifdef USE_OPENSSL /* XXX look into ERR_error_string */
-						ERR_print_errors_fp (stdout);
-#  endif /* USE_OPENSSL */
-				}
-		} else {
-				printf ("%s\n", _("CRITICAL - Cannot initiate SSL handshake."));
-		}
-		return STATE_CRITICAL;
+        SSL_set_fd (s, sd);
+		if (SSL_connect(s) == 1)
+		    return OK;
+
+    // Try TLS
+    // Free old pointers
+    SSL_CTX_free(c);
+    SSL_free(s);
+
+    if ((c = SSL_CTX_new(TLSv1_client_method())) == NULL) {
+        printf("%s\n", _("CRITICAL - Cannot create SSL context."));
+        return STATE_CRITICAL;
+    }
+    if ((s = SSL_new(c)) == NULL) {
+        printf("%s\n", _("CRITICAL - Cannot initiate SSL handshake."));
+        return STATE_CRITICAL;
+    }
+#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;
+    }
+    return STATE_CRITICAL;				    
 }
 
 void np_net_ssl_cleanup (){