From 355c7ec72a45c68f4366f33d765ad5e4f8b49e21 Mon Sep 17 00:00:00 2001 From: akarl10 Date: Sun, 13 Nov 2022 11:45:37 +0100 Subject: [PATCH] rdg: Fallback to rpc if http status is not sent It seems MS RDG 2016+ does not send a http status code if something with the request or configuration is not ok. It is worth retrying with rpc in that case --- libfreerdp/core/gateway/rdg.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/libfreerdp/core/gateway/rdg.c b/libfreerdp/core/gateway/rdg.c index b2a216c9b..d5f13f077 100644 --- a/libfreerdp/core/gateway/rdg.c +++ b/libfreerdp/core/gateway/rdg.c @@ -1771,9 +1771,18 @@ static BOOL rdg_establish_data_connection(rdpRdg* rdg, rdpTls* tls, const char* return FALSE; response = http_response_recv(tls, TRUE); - + /* MS RD Gateway seems to just terminate the tls connection without + * sending an answer if it is not happy with the http request */ if (!response) + { + WLog_INFO(TAG, "RD Gateway HTTP transport broken."); + http_context_enable_websocket_upgrade(rdg->http, FALSE); + if (rpcFallback) + *rpcFallback = TRUE; + credssp_auth_free(rdg->auth); + rdg->auth = NULL; return FALSE; + } StatusCode = http_response_get_status_code(response); @@ -1788,6 +1797,8 @@ static BOOL rdg_establish_data_connection(rdpRdg* rdg, rdpTls* tls, const char* *rpcFallback = TRUE; http_response_free(response); + credssp_auth_free(rdg->auth); + rdg->auth = NULL; return FALSE; } default: @@ -1811,7 +1822,15 @@ static BOOL rdg_establish_data_connection(rdpRdg* rdg, rdpTls* tls, const char* response = http_response_recv(tls, TRUE); if (!response) + { + WLog_INFO(TAG, "RD Gateway HTTP transport broken."); + http_context_enable_websocket_upgrade(rdg->http, FALSE); + if (rpcFallback) + *rpcFallback = TRUE; + credssp_auth_free(rdg->auth); + rdg->auth = NULL; return FALSE; + } } } credssp_auth_free(rdg->auth); @@ -1828,7 +1847,13 @@ static BOOL rdg_establish_data_connection(rdpRdg* rdg, rdpTls* tls, const char* response = http_response_recv(tls, TRUE); if (!response) + { + WLog_INFO(TAG, "RD Gateway HTTP transport broken."); + http_context_enable_websocket_upgrade(rdg->http, FALSE); + if (rpcFallback) + *rpcFallback = TRUE; return FALSE; + } } statusCode = http_response_get_status_code(response);