System.Net.Security.SslStream.AuthenticateAsClient C# (CSharp) Method

AuthenticateAsClient() public method

public AuthenticateAsClient ( string targetHost ) : void
targetHost string
return void
        public virtual void AuthenticateAsClient(string targetHost)
        {
            AuthenticateAsClient(targetHost, new X509CertificateCollection(), SecurityProtocol.SystemDefaultSecurityProtocols, false);
        }

Same methods

SslStream::AuthenticateAsClient ( string targetHost, System clientCertificates, System enabledSslProtocols, bool checkCertificateRevocation ) : void
SslStream::AuthenticateAsClient ( string targetHost, System clientCertificates, bool checkCertificateRevocation ) : void
SslStream::AuthenticateAsClient ( string targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation ) : void
SslStream::AuthenticateAsClient ( string targetHost, X509CertificateCollection clientCertificates, bool checkCertificateRevocation ) : void

Usage Example

Example #1
1
        static void Test()
        {
            // Connect as client to port 1300
            string server = "127.0.0.1";
            TcpClient client = new TcpClient(server, 1300);

            // Create a secure stream
            using (SslStream sslStream = new SslStream(client.GetStream(), false,
                new RemoteCertificateValidationCallback(ValidateServerCertificate), null))
            {
                sslStream.AuthenticateAsClient(server);

                // ... Send and read data over the stream
                byte[] buffer = new byte[1024];
                int n = sslStream.Read(buffer, 0, 1024);


                string _message = System.Text.Encoding.UTF8.GetString(buffer, 0, n);
                System.Console.WriteLine("Client said: " + _message); 

            }

            // Disconnect and close the client
            client.Close();
        }
All Usage Examples Of System.Net.Security.SslStream::AuthenticateAsClient