From 583d6ac96e97d5fc0b9353a7ce17f4451c4f004d Mon Sep 17 00:00:00 2001 From: Mathieu CARBONNEAUX Date: Sun, 7 Aug 2016 19:47:51 +0200 Subject: [PATCH] SNI support add SNI support --- .gitignore | 3 +++ Makefile | 2 +- http.c | 2 +- ptstream.c | 17 +++++++++-------- 4 files changed, 14 insertions(+), 10 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..90f3fef --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +*.o +*.exec +proxytunnel.exe diff --git a/Makefile b/Makefile index 8d1300c..b378a73 100644 --- a/Makefile +++ b/Makefile @@ -78,7 +78,7 @@ OBJ = proxytunnel.o \ .PHONY: all clean docs install -all: proxytunnel docs +all: proxytunnel docs: $(MAKE) -C docs diff --git a/http.c b/http.c index eb9f88f..b88f812 100644 --- a/http.c +++ b/http.c @@ -109,7 +109,7 @@ void proxy_protocol(PTSTREAM *pts) { } else { if( args_info.verbose_flag ) message( "\nTunneling to %s (destination)\n", args_info.dest_arg ); - sprintf( buf, "CONNECT %s HTTP/1.1\r\nHost: %s\r\n", args_info.dest_arg, args_info.host_arg ? args_info.host_arg : args_info.dest_arg ); + sprintf( buf, "CONNECT %s HTTP/1.1\r\nHost: %s\r\n", args_info.dest_arg, args_info.host_arg ? args_info.host_arg : args_info.proxyhost_arg ); } if ( args_info.user_given && args_info.pass_given ) { diff --git a/ptstream.c b/ptstream.c index 5edd271..4f16d40 100644 --- a/ptstream.c +++ b/ptstream.c @@ -162,18 +162,19 @@ int stream_enable_ssl(PTSTREAM *pts) { ctx = SSL_CTX_new (meth); ssl = SSL_new (ctx); + SSL_set_rfd (ssl, stream_get_incoming_fd(pts)); + SSL_set_wfd (ssl, stream_get_outgoing_fd(pts)); + /* SNI support */ if ( args_info.verbose_flag ) { message( "Set SNI hostname to %s\n", args_info.proxyhost_arg ); - } - res = SSL_set_tlsext_host_name(ssl,args_info.proxyhost_arg); - if (res < 0) { - message( "TLS SNI error, giving up: SSL_set_tlsext_host_name returned error message:\n %u\n", res ); - exit( 1 ); - } + } + res = SSL_set_tlsext_host_name(ssl,args_info.proxyhost_arg); + if (res < 0) { + message( "TLS SNI error, giving up: SSL_set_tlsext_host_name returned error message:\n %u\n", res ); + exit( 1 ); + } - SSL_set_rfd (ssl, stream_get_incoming_fd(pts)); - SSL_set_wfd (ssl, stream_get_outgoing_fd(pts)); SSL_connect (ssl); /* Store ssl and ctx parameters */