コード例 #1
0
        public void TestSslClientAuthenticationException()
        {
            var location = new IPEndPoint(IPAddress.Loopback, 5055);

            server = new SslServer(location)
            {
                ServerCertificate  = SslServer.LoadCertificate(serverCert),
                AuthenticateClient = true
            };
            server.Start();

            SslClient client =
                new SslClient(location)
            {
                ServerName   = "MyServerName",
                Protocol     = SslProtocols.Default,
                Certificates = null
            };

            try
            {
                client.Connect();

                string echo = client.Echo("Hello World");
                Assert.AreEqual(echo, "Hello World");
            }
            finally
            {
                client.Close();
                server.Stop();
                client = null;
            }
        }
コード例 #2
0
        public void TestSslServerAuthentication()
        {
            var location = new IPEndPoint(IPAddress.Loopback, 5055);

            Console.WriteLine(Directory.GetCurrentDirectory());
            server = new SslServer(location)
            {
                ServerCertificate =
                    SslServer.LoadCertificate(serverCert)
            };
            server.Start();

            SslClient client =
                new SslClient(location)
            {
                ServerName = "MyServerName",
                Protocol   = SslProtocols.Default
            };

            try
            {
                client.Connect();

                string echo = client.Echo("Hello World");
                Assert.AreEqual(echo, "Hello World");
            }
            finally
            {
                client.Close();
                server.Stop();
                client = null;
            }
        }