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

AuthenticateAsClientAsync() public method

public AuthenticateAsClientAsync ( string targetHost ) : System.Threading.Tasks.Task
targetHost string
return System.Threading.Tasks.Task
        public virtual System.Threading.Tasks.Task AuthenticateAsClientAsync(string targetHost) { throw null; }
        public virtual System.Threading.Tasks.Task AuthenticateAsClientAsync(string targetHost, System.Security.Cryptography.X509Certificates.X509CertificateCollection clientCertificates, System.Security.Authentication.SslProtocols enabledSslProtocols, bool checkCertificateRevocation) { throw null; }

Same methods

SslStream::AuthenticateAsClientAsync ( string targetHost, System clientCertificates, System enabledSslProtocols, bool checkCertificateRevocation ) : System.Threading.Tasks.Task
SslStream::AuthenticateAsClientAsync ( string targetHost, System clientCertificates, bool checkCertificateRevocation ) : System.Threading.Tasks.Task
SslStream::AuthenticateAsClientAsync ( string targetHost ) : Task
SslStream::AuthenticateAsClientAsync ( string targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation ) : Task
SslStream::AuthenticateAsClientAsync ( string targetHost, X509CertificateCollection clientCertificates, bool checkCertificateRevocation ) : Task

Usage Example

Example #1
0
        /// <summary>
        /// Initializes a client instance of <see cref="DesktopNetworkStream"/>.
        /// </summary>
        /// <param name="host">Network host.</param>
        /// <param name="port">Network port.</param>
        /// <param name="useTls">Use TLS layer?</param>
        /// <param name="noDelay">No delay?</param>
        /// <param name="ignoreSslPolicyErrors">Ignore SSL policy errors?</param>
        internal DesktopNetworkStream(string host, int port, bool useTls, bool noDelay, bool ignoreSslPolicyErrors)
        {
            this.Host = host;
            this.Port = port;
#if NETSTANDARD
            this.tcpClient = new TcpClient { NoDelay = noDelay };
            this.tcpClient.ConnectAsync(host, port).Wait();
#else
            this.tcpClient = new TcpClient(host, port) { NoDelay = noDelay };
#endif

            Stream stream = this.tcpClient.GetStream();
            if (useTls)
            {
                var ssl = new SslStream(
                    stream,
                    false,
                    (sender, certificate, chain, errors) => errors == SslPolicyErrors.None || ignoreSslPolicyErrors);
#if NETSTANDARD
                ssl.AuthenticateAsClientAsync(host).Wait();
#else
                ssl.AuthenticateAsClient(host);
#endif
                stream = ssl;
            }

            this.networkStream = stream;
        }
All Usage Examples Of System.Net.Security.SslStream::AuthenticateAsClientAsync