Fix connection negotiation with mstsc/msrdc

mstsc/msrdc includes an optional correlation info
(RDP_NEG_CORRELATION_INFO) during connection negotiation. This confuses
FreeRDP which interpret this as a cookie and eventually fails the
negotiation, preventing a successful connection to these RDP client.

This commit addresses 3 things.

1) When processing connection token or cookie, skip if the remaining
bytes are neither.
2) After processing the RDP_NEG_REQ info, skip the optional correlation
info (RDP_NEG_CORRELATION_INFO) if one is present.
3) Allow local connection without server certificate when the client
inherently trust the server.
This commit is contained in:
Steve Pronovost 2021-10-16 09:22:58 -07:00 committed by akallabeth
parent a71235be74
commit 592f8d95be

View File

@ -744,6 +744,11 @@ static BOOL nego_read_request_token_or_cookie(rdpNego* nego, wStream* s)
if (memcmp(Stream_Pointer(s), "Cookie: mstshash=", 17) != 0)
{
if (memcmp(Stream_Pointer(s), "Cookie: msts=", 13) != 0)
{
/* remaining bytes are neither a token nor a cookie */
return TRUE;
}
isToken = TRUE;
}
else
@ -842,6 +847,14 @@ BOOL nego_read_request(rdpNego* nego, wStream* s)
return FALSE;
}
/* Skip over optional RDP_NEG_CORRELATION_INFO
* see MS-RDPBCGR 2.2.1.1.2 RDP Correlation Info (RDP_NEG_CORRELATION_INFO)
*/
if (Stream_GetRemainingLength(s) >= 36)
{
Stream_Seek(s, 36);
}
return tpkt_ensure_stream_consumed(s, length);
}
@ -1183,8 +1196,8 @@ BOOL nego_send_negotiation_response(rdpNego* nego)
settings->UseRdpSecurityLayer = FALSE;
settings->EncryptionLevel = ENCRYPTION_LEVEL_NONE;
}
if (!settings->RdpServerRsaKey && !settings->RdpKeyFile && !settings->RdpKeyContent)
else if (!settings->RdpServerRsaKey && !settings->RdpKeyFile &&
!settings->RdpKeyContent)
{
WLog_ERR(TAG, "Missing server certificate");
return FALSE;