/// <summary> /// Constructor /// </summary> /// <param name="socket"></param> /// <param name="targetHost"></param> /// <param name="autoHandle"></param> public RdpemtClient(RdpeudpSocket socket, string targetHost, bool autoHandle = true) : base(autoHandle) { if (!socket.AutoHandle) { throw new NotSupportedException("To Create RDPEMT Server, RDPEUDP Socket must be auto handle."); } if (socket.TransMode == TransportMode.Reliable) { RdpeudpTLSChannel secChannel = new RdpeudpTLSChannel(socket); secChannel.Received += ReceiveBytes; secChannel.AuthenticateAsClient(targetHost); this.secureChannel = secChannel; } else { RdpeudpDTLSChannel secChannel = new RdpeudpDTLSChannel(socket); secChannel.Received += ReceiveBytes; secChannel.AuthenticateAsClient(targetHost); this.secureChannel = secChannel; } bandwidthMeasureStartTime = DateTime.Now; bandwidthMeasurePayloadByteCount = 0; detectBandwidth = false; }
/// <summary> /// Constructor /// </summary> /// <param name="socket"></param> /// <param name="targetHost"></param> /// <param name="autoHandle"></param> /// <param name="selectedSslProtocols">The selected SSL protocols.</param> public RdpemtClient(RdpeudpSocket socket, string targetHost, bool autoHandle = true, SslProtocols selectedSslProtocols = SslProtocols.Tls) : base(autoHandle) { if (!socket.AutoHandle) { throw new NotSupportedException("To Create RDPEMT Server, RDPEUDP Socket must be auto handle."); } if (socket.TransMode == TransportMode.Reliable) { RdpeudpTLSChannel secChannel = new RdpeudpTLSChannel(socket); secChannel.Received += ReceiveBytes; secChannel.AuthenticateAsClient(targetHost, selectedSslProtocols); this.secureChannel = secChannel; } else { RdpeudpDTLSChannel secChannel = new RdpeudpDTLSChannel(socket); secChannel.Received += ReceiveBytes; secChannel.AuthenticateAsClient(targetHost); this.secureChannel = secChannel; } Initialize(); }
public void S1_Connection_Initialization_NegativeTest_InitialLossyConnection_RDPEncryption() { Site.Log.Add(LogEntryKind.Debug, "Establishing RDP connection, used RDP encryption"); StartRDPConnection(true); this.TestSite.Log.Add(LogEntryKind.Comment, "Create a {0} UDP connection.", TransportMode.Lossy); this.EstablishUDPConnection(TransportMode.Lossy, waitTime); this.TestSite.Log.Add(LogEntryKind.Comment, "Start DTLS handshake."); String certFile = this.Site.Properties["CertificatePath"]; String certPwd = this.Site.Properties["CertificatePassword"]; X509Certificate2 cert = new X509Certificate2(certFile, certPwd); RdpeudpDTLSChannel sChannel = new RdpeudpDTLSChannel(rdpeudpSocketL); sChannel.AuthenticateAsServer(cert); this.TestSite.Log.Add(LogEntryKind.Comment, "Expect for Client Initiate Multitransport Error PDU to indicate Client drop RDP-UDP connection"); this.rdpbcgrAdapter.WaitForPacket<Client_Initiate_Multitransport_Response_PDU>(waitTime); if (requestIdList.Count == 1) VerifyClientInitiateMultitransportResponsePDU(rdpbcgrAdapter.SessionContext.ClientInitiateMultitransportResponsePDU, requestIdList[0]); }
/// <summary> /// Constructor /// </summary> /// <param name="socket"></param> /// <param name="cert"></param> /// <param name="autoHandle"></param> public RdpemtServer(RdpeudpSocket socket, X509Certificate2 cert, bool autoHandle = true) : base(autoHandle) { if (!socket.AutoHandle) { throw new NotSupportedException("To Create RDPEMT Server, RDPEUDP Socket must be auto handle."); } if (socket.TransMode == TransportMode.Reliable) { RdpeudpTLSChannel secChannel = new RdpeudpTLSChannel(socket); secChannel.Received += ReceiveBytes; secChannel.AuthenticateAsServer(cert); this.secureChannel = secChannel; } else { RdpeudpDTLSChannel secChannel = new RdpeudpDTLSChannel(socket); secChannel.Received += ReceiveBytes; secChannel.AuthenticateAsServer(cert); this.secureChannel = secChannel; } }
/// <summary> /// Get the First valid UDP Source Packet. /// </summary> /// <param name="udpTransportMode"></param> /// <returns></returns> private RdpeudpPacket GetFirstValidUdpPacket(TransportMode udpTransportMode) { byte[] dataToSent = null; RdpeudpPacket firstPacket = null; String certFile = this.Site.Properties["CertificatePath"]; String certPwd = this.Site.Properties["CertificatePassword"]; X509Certificate2 cert = new X509Certificate2(certFile, certPwd); if (udpTransportMode == TransportMode.Reliable) { RdpeudpTLSChannel secChannel = new RdpeudpTLSChannel(rdpeudpSocketR); secChannel.AuthenticateAsServer(cert); RdpeudpPacket packet = rdpeudpSocketR.ExpectPacket(waitTime); if (packet.payload != null) { rdpeudpSocketR.ProcessSourceData(packet); // Process Source Data to makesure ACK Vector created next is correct secChannel.ReceiveBytes(packet.payload); } dataToSent = secChannel.GetDataToSent(waitTime); firstPacket = rdpeudpSocketR.CreateSourcePacket(dataToSent); } else { RdpeudpDTLSChannel secChannel = new RdpeudpDTLSChannel(rdpeudpSocketL); secChannel.AuthenticateAsServer(cert); RdpeudpPacket packet = rdpeudpSocketL.ExpectPacket(waitTime); if (packet.payload != null) { rdpeudpSocketL.ProcessSourceData(packet); // Process Source Data to makesure ACK Vector created next is correct secChannel.ReceiveBytes(packet.payload); } dataToSent = secChannel.GetDataToSent(waitTime); firstPacket = rdpeudpSocketL.CreateSourcePacket(dataToSent); } return firstPacket; }