Fallback to RDG RPC transport only if server does not support RDG HTTP and

error out in other cases - invalid RDG SSL cert, bad credentials, PAA failue, etc.
This commit is contained in:
Pavel Pautov 2018-04-17 17:05:20 -07:00
parent c60388954b
commit a0019ec79c
3 changed files with 16 additions and 8 deletions

View File

@ -733,7 +733,7 @@ static BOOL rdg_tls_connect(rdpRdg* rdg, rdpTls* tls, const char* peerAddress, i
}
static BOOL rdg_establish_data_connection(rdpRdg* rdg, rdpTls* tls,
const char* method, const char* peerAddress, int timeout)
const char* method, const char* peerAddress, int timeout, BOOL* rpcFallback)
{
HttpResponse* response = NULL;
int statusCode;
@ -754,6 +754,14 @@ static BOOL rdg_establish_data_connection(rdpRdg* rdg, rdpTls* tls,
if (!response)
return FALSE;
if (response->StatusCode == HTTP_STATUS_NOT_FOUND)
{
WLog_INFO(TAG, "RD Gateway does not support HTTP transport.");
if (rpcFallback) *rpcFallback = TRUE;
http_response_free(response);
return FALSE;
}
if (!rdg_handle_ntlm_challenge(rdg->ntlm, response))
{
http_response_free(response);
@ -824,7 +832,7 @@ static BOOL rdg_tunnel_connect(rdpRdg* rdg)
return TRUE;
}
BOOL rdg_connect(rdpRdg* rdg, const char* hostname, UINT16 port, int timeout)
BOOL rdg_connect(rdpRdg* rdg, int timeout, BOOL* rpcFallback)
{
BOOL status;
int outConnSocket = 0;
@ -832,7 +840,7 @@ BOOL rdg_connect(rdpRdg* rdg, const char* hostname, UINT16 port, int timeout)
assert(rdg != NULL);
status = rdg_establish_data_connection(
rdg, rdg->tlsOut, "RDG_OUT_DATA", NULL, timeout);
rdg, rdg->tlsOut, "RDG_OUT_DATA", NULL, timeout, rpcFallback);
if (status)
{
@ -843,7 +851,7 @@ BOOL rdg_connect(rdpRdg* rdg, const char* hostname, UINT16 port, int timeout)
peerAddress = freerdp_tcp_get_peer_address(outConnSocket);
status = rdg_establish_data_connection(
rdg, rdg->tlsIn, "RDG_IN_DATA", peerAddress, timeout);
rdg, rdg->tlsIn, "RDG_IN_DATA", peerAddress, timeout, NULL);
free(peerAddress);
}

View File

@ -138,8 +138,7 @@ struct rdp_rdg
FREERDP_LOCAL rdpRdg* rdg_new(rdpTransport* transport);
FREERDP_LOCAL void rdg_free(rdpRdg* rdg);
FREERDP_LOCAL BOOL rdg_connect(rdpRdg* rdg, const char* hostname, UINT16 port,
int timeout);
FREERDP_LOCAL BOOL rdg_connect(rdpRdg* rdg, int timeout, BOOL* rpcFallback);
FREERDP_LOCAL DWORD rdg_get_event_handles(rdpRdg* rdg, HANDLE* events,
DWORD count);

5
libfreerdp/core/transport.c Normal file → Executable file
View File

@ -354,6 +354,7 @@ BOOL transport_connect(rdpTransport* transport, const char* hostname,
rdpSettings* settings = transport->settings;
rdpContext* context = transport->context;
transport->async = settings->AsyncTransport;
BOOL rpcFallback = !settings->GatewayHttpTransport;
if (transport->GatewayEnabled)
{
@ -364,7 +365,7 @@ BOOL transport_connect(rdpTransport* transport, const char* hostname,
if (!transport->rdg)
return FALSE;
status = rdg_connect(transport->rdg, hostname, port, timeout);
status = rdg_connect(transport->rdg, timeout, &rpcFallback);
if (status)
{
@ -380,7 +381,7 @@ BOOL transport_connect(rdpTransport* transport, const char* hostname,
}
}
if (!status && settings->GatewayRpcTransport)
if (!status && settings->GatewayRpcTransport && rpcFallback)
{
transport->tsg = tsg_new(transport);