/// <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;
        }
示例#2
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>
        /// 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;
            }
        }
        public void S1_Connection_Initialization_NegativeTest_InitialReliableConnection_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.Reliable);
            this.EstablishUDPConnection(TransportMode.Reliable, waitTime);

            this.TestSite.Log.Add(LogEntryKind.Comment, "Start TLS handshake.");
            String certFile = this.Site.Properties["CertificatePath"];
            String certPwd = this.Site.Properties["CertificatePassword"];
            X509Certificate2 cert = new X509Certificate2(certFile, certPwd);
            RdpeudpTLSChannel sChannel = new RdpeudpTLSChannel(rdpeudpSocketR);
            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>
        /// 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;
        }