/// <summary> /// Called by servers to authenticate the server and optionally the client in /// a client-server connection using the specified certificate. /// </summary> /// <param name="cert">The certificate used to authenticate the server.</param> public void AuthenticateAsServer(X509Certificate cert) { // Using thread in threadpool to manage the authentication process ThreadPool.QueueUserWorkItem(AuthenticateAsServer, cert); DateTime endtime = DateTime.Now + timeout; if (rdpeudpSocket.AutoHandle) { // If the transport is Autohandle, send packets during authentication automatically TimeSpan waittime = new TimeSpan(0, 0, 1); while (!isAuthenticated && DateTime.Now < endtime) { byte[] bytesToSend = innerStream.GetDataToSent(waittime); if (bytesToSend != null && bytesToSend.Length > 0) { rdpeudpSocket.Send(bytesToSend); } } if (!isAuthenticated) { throw new TimeoutException("Time out when Authenticate as Server!"); } } else { // If the transport is not Autohandle, return, not send packet automatically } }
/// <summary> /// Send bytes through this security channel /// </summary> /// <param name="data"></param> /// <param name="timeout"></param> public void Send(byte[] data) { if (data != null && data.Length > 0) { List <byte[]> toSentList = Encrypt(data); if (toSentList != null) { foreach (byte[] toSentData in toSentList) { rdpeudpSocket.Send(toSentData); } } // ETW Provider Dump Message string messageName = "RDPEMT:SentPDU"; // ExtendedLogger.DumpMessage(messageName, RdpbcgrUtility.DumpLevel_Layer2, "RDPEMT Sent PDU", data); } }