Skip to content

Commit

Permalink
SNI support
Browse files Browse the repository at this point in the history
add SNI support
  • Loading branch information
mcarbonneaux committed Aug 7, 2016
1 parent 9883226 commit 583d6ac
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
3 changes: 3 additions & 0 deletions .gitignore
@@ -0,0 +1,3 @@
*.o
*.exec
proxytunnel.exe
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -78,7 +78,7 @@ OBJ = proxytunnel.o \

.PHONY: all clean docs install

all: proxytunnel docs
all: proxytunnel

docs:
$(MAKE) -C docs
Expand Down
2 changes: 1 addition & 1 deletion http.c
Expand Up @@ -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 ) {
Expand Down
17 changes: 9 additions & 8 deletions ptstream.c
Expand Up @@ -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 */
Expand Down

0 comments on commit 583d6ac

Please sign in to comment.