Ejemplo n.º 1
0
        public void Init()
        {
            FakeClient.OnClientReceivedData += Proxy_FakeClient_OnClientReceivedData;
            Client.OnClientReceivedData     += Proxy_Client_OnClientReceivedData;

            FakeClient.OnClientDisconnected += Proxy_FakeClient_OnClientDisconnected;
            Client.OnClientDisconnected     += Proxy_Client_OnClientDisconnected;

            ClientMessageInformation = new MessageInformation(true);
            ServerMessageInformation = new MessageInformation(false);

            ClientMessageInformation.OnMessageParsed += ClientMessageInformation_OnMessageParsed;
            ServerMessageInformation.OnMessageParsed += ServerMessageInformation_OnMessageParsed;

            FakeClient.Connect(FakeClientRemoteIp);
        }
Ejemplo n.º 2
0
        public void TestSslConnectOnPlainTextPortFailure()
        {
            Assert.Throws <ArgumentNullException> (() => new FakeClient(null));

            using (var client = new FakeClient(new NullProtocolLogger())) {
                try {
                    client.Connect("www.google.com", 80, SecureSocketOptions.SslOnConnect);
                    Assert.Fail("SSL handshake should have failed with www.google.com:80.");
                } catch (SslHandshakeException ex) {
                    Assert.IsNull(ex.ServerCertificate, "ServerCertificate");
                    Assert.IsNull(ex.RootCertificateAuthority, "RootCertificateAuthority");
                } catch (Exception ex) {
                    Assert.Ignore("SSL handshake failure inconclusive: {0}", ex);
                }
            }
        }
Ejemplo n.º 3
0
        public void TestSslCertificateValidationFailure()
        {
            Assert.Throws <ArgumentNullException> (() => new FakeClient(null));

            using (var client = new FakeClient(new NullProtocolLogger())) {
                try {
                    client.Connect("untrusted-root.badssl.com", 443, SecureSocketOptions.SslOnConnect);
                    Assert.Fail("SSL handshake should have failed with untrusted-root.badssl.com.");
                } catch (SslHandshakeException ex) {
                    Assert.NotNull(ex.ServerCertificate, "ServerCertificate");
                    AssertServerCertificate((X509Certificate2)ex.ServerCertificate);

                    // Note: This is null on Mono because Mono provides an empty chain.
                    if (ex.RootCertificateAuthority is X509Certificate2 root)
                    {
                        AssertRootCertificate(root);
                    }
                } catch (Exception ex) {
                    Assert.Ignore("SSL handshake failure inconclusive: {0}", ex);
                }
            }
        }
Ejemplo n.º 4
0
 public static void HandleSelectedServerDataMessage(FakeClient client, SelectedServerDataMessage message)
 {
     client.Disconnect(true);
     //client.Ticket = message.ticket;
     client.Connect(message.address, message.port);
 }