Exemplo n.º 1
0
        public void S1_Connection_Initialization_NegativeTest_InitialLossyConnection_RDPEncryption()
        {
            CheckPlatformCompatibility(TransportMode.Lossy);

            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;

            PtfPropUtility.GetPtfPropertyValue(Site, "CertificatePath", out certFile);

            String certPwd;

            PtfPropUtility.GetPtfPropertyValue(Site, "CertificatePassword", out certPwd);

            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>
        /// 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;

            PtfPropUtility.GetPtfPropertyValue(Site, "CertificatePath", out certFile);

            String certPwd;

            PtfPropUtility.GetPtfPropertyValue(Site, "CertificatePassword", out certPwd);

            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 make sure ACK Vector created next is correct
                    secChannel.ReceiveBytes(packet.payload);
                }
                dataToSent = secChannel.GetDataToSent(waitTime);

                // Make sure this test packet does not exceed upstream MTU.
                int maxPayloadsize = GetMaxiumPayloadSizeForSourcePacket(rdpeudpSocketR.UUpStreamMtu);

                dataToSent = dataToSent.Take(maxPayloadsize).ToArray();

                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 make sure ACK Vector created next is correct
                    secChannel.ReceiveBytes(packet.payload);
                }
                dataToSent = secChannel.GetDataToSent(waitTime);

                // Make sure this test packet does not exceed upstream MTU.
                int maxPayloadsize = GetMaxiumPayloadSizeForSourcePacket(rdpeudpSocketL.UUpStreamMtu);

                dataToSent = dataToSent.Take(maxPayloadsize).ToArray();

                firstPacket = rdpeudpSocketL.CreateSourcePacket(dataToSent);
            }

            return(firstPacket);
        }
        /// <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);
        }