Fallback to RDG RPC transport only if server does not support RDG HTTP and
authorPavel Pautov <37922380+p-pautov@users.noreply.github.com>
Wed, 18 Apr 2018 00:05:20 +0000 (17:05 -0700)
committerPavel Pautov <37922380+p-pautov@users.noreply.github.com>
Thu, 26 Apr 2018 01:36:43 +0000 (18:36 -0700)
error out in other cases - invalid RDG SSL cert, bad credentials, PAA failue, etc.

libfreerdp/core/gateway/rdg.c
libfreerdp/core/gateway/rdg.h
libfreerdp/core/transport.c [changed mode: 0644->0755]

index 3dab0f4..2eac656 100755 (executable)
@@ -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);
        }
index 2dfbbc5..f4fa95c 100755 (executable)
@@ -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);
 
old mode 100644 (file)
new mode 100755 (executable)
index ad44e0a..59ee8cf
@@ -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);