aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Thomas Guyot-Sionnest <dermoth@aei.ca> 2009-05-20 01:05:35 -0400
committerGravatar Thomas Guyot-Sionnest <dermoth@aei.ca> 2009-05-20 01:05:35 -0400
commit0489df95fc5ab2c84cd7830df97942a874e431d9 (patch)
treebe2615d44c1f1b86cf668ce55c5e42dc3e3c28f8
parent56cf66c9b815ed953245476b7c715f15cf053763 (diff)
downloadmonitoring-plugins-0489df95fc5ab2c84cd7830df97942a874e431d9.tar.gz
check_http: Add SSL/TLS hostname extension support (SNI) - (#1939022 - Joe Presbrey)
-rw-r--r--NEWS1
-rw-r--r--THANKS.in1
-rw-r--r--plugins/check_http.c2
-rw-r--r--plugins/netutils.h1
-rw-r--r--plugins/sslutils.c13
5 files changed, 16 insertions, 2 deletions
diff --git a/NEWS b/NEWS
index 25009822..c5d820f8 100644
--- a/NEWS
+++ b/NEWS
@@ -34,6 +34,7 @@ This file documents the major additions and syntax changes between releases.
Fixed typos for check_disk (Chris Pepper)
Fixed check_mysql* not using password set in my.cnf (#2531905 - Ben Timby) - Specify an empty password explicitly if you need to override it.
Fixed awk subst.in/subst script path error (#2722832 - Martin Foster)
+ check_http: Add SSL/TLS hostname extension support (SNI) - (#1939022 - Joe Presbrey)
1.4.13 25th Sept 2008
Fix Debian bug #460097: check_http --max-age broken (Hilko Bengen)
diff --git a/THANKS.in b/THANKS.in
index b173eb6e..9209bcfc 100644
--- a/THANKS.in
+++ b/THANKS.in
@@ -252,3 +252,4 @@ Oskar Ahner
Chris Pepper
Ben Timby
Martin Foster
+Joe Presbrey
diff --git a/plugins/check_http.c b/plugins/check_http.c
index 03102033..79f6adf3 100644
--- a/plugins/check_http.c
+++ b/plugins/check_http.c
@@ -790,7 +790,7 @@ check_http (void)
die (STATE_CRITICAL, _("HTTP CRITICAL - Unable to open TCP socket\n"));
#ifdef HAVE_SSL
if (use_ssl == TRUE) {
- np_net_ssl_init(sd);
+ np_net_ssl_init_with_hostname(sd, host_name);
if (check_cert == TRUE) {
result = np_net_ssl_check_cert(days_till_exp);
np_net_ssl_cleanup();
diff --git a/plugins/netutils.h b/plugins/netutils.h
index b479b741..572a3ae2 100644
--- a/plugins/netutils.h
+++ b/plugins/netutils.h
@@ -99,6 +99,7 @@ extern int address_family;
#ifdef HAVE_SSL
/* maybe this could be merged with the above np_net_connect, via some flags */
int np_net_ssl_init(int sd);
+int np_net_ssl_init_with_hostname(int sd, char *host_name);
void np_net_ssl_cleanup();
int np_net_ssl_write(const void *buf, int num);
int np_net_ssl_read(void *buf, int num);
diff --git a/plugins/sslutils.c b/plugins/sslutils.c
index 1d4ef94a..aa571b6c 100644
--- a/plugins/sslutils.c
+++ b/plugins/sslutils.c
@@ -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) {