Skip to content

Commit 9b50788

Browse files
authored
Attach tls handler in proper spot when doing nested tls (#301)
* Attach tls handler in proper spot when doing nested tls
1 parent 629afd2 commit 9b50788

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

source/proxy_connection.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -448,12 +448,17 @@ static void s_aws_http_on_stream_complete_tls_proxy(struct aws_http_stream *stre
448448
context->state = AWS_PBS_TLS_NEGOTIATION;
449449
struct aws_channel *channel = aws_http_connection_get_channel(context->connection);
450450

451-
/*
452-
* TODO: if making secure (double TLS) proxy connection, we need to go after the second slot:
453-
*
454-
* Socket -> TLS(proxy) -> TLS(origin server) -> Http
455-
*/
456-
if (channel == NULL || s_vtable->setup_client_tls(aws_channel_get_first_slot(channel), context->tls_options)) {
451+
struct aws_channel_slot *left_of_tls_slot = aws_channel_get_first_slot(channel);
452+
if (context->proxy_config->tls_options != NULL) {
453+
/*
454+
* If making secure (double TLS) proxy connection, we need to go after the second slot:
455+
*
456+
* Socket -> TLS(proxy) -> TLS(origin server) -> Http
457+
*/
458+
left_of_tls_slot = left_of_tls_slot->adj_right;
459+
}
460+
461+
if (s_vtable->setup_client_tls(left_of_tls_slot, context->tls_options)) {
457462
AWS_LOGF_ERROR(
458463
AWS_LS_HTTP_CONNECTION,
459464
"(%p) Proxy connection failed to start TLS negotiation with error %d(%s)",

0 commit comments

Comments
 (0)