diff --git a/src/client.c b/src/client.c index bc46362..97b80c8 100644 --- a/src/client.c +++ b/src/client.c @@ -701,7 +701,7 @@ __init_connection(CONN *C, URL U, CLIENT *client) https_tunnel_response(C); } C->encrypt = TRUE; - if (SSL_initialize(C)==FALSE) { + if (SSL_initialize(C, url_get_hostname(U))==FALSE) { return FALSE; } } diff --git a/src/ssl.c b/src/ssl.c index 711bfac..d2c7020 100644 --- a/src/ssl.c +++ b/src/ssl.c @@ -40,6 +40,7 @@ #include #include +#include #include #include #include @@ -62,8 +63,8 @@ private void SSL_error_stack(void); private void SSL_pthreads_locking_callback(int m, int t, char *f, int l); #endif/*HAVE_SSL*/ -BOOLEAN -SSL_initialize(CONN *C) +BOOLEAN +SSL_initialize(CONN *C, const char *servername) { #ifdef HAVE_SSL int i; @@ -138,6 +139,7 @@ SSL_initialize(CONN *C) SSL_error_stack(); return FALSE; } + SSL_ctrl(C->ssl, SSL_CTRL_SET_TLSEXT_HOSTNAME, TLSEXT_NAMETYPE_host_name, servername); SSL_set_fd(C->ssl, C->sock); serr = SSL_connect(C->ssl); if (serr != 1) { diff --git a/src/ssl.h b/src/ssl.h index 26ea74e..477149b 100644 --- a/src/ssl.h +++ b/src/ssl.h @@ -49,7 +49,7 @@ #endif/*HAVE_SSL*/ -BOOLEAN SSL_initialize(CONN *C); +BOOLEAN SSL_initialize(CONN *C, const char *servername); void SSL_thread_setup(void); void SSL_thread_cleanup(void);