System.Net.Security.SslStream.AuthenticateAsClientAsync Method

Called by clients to authenticate the server and optionally the client in a client-server connection as an asynchronous operation. The authentication process uses the specified certificate collection and SSL protocol.

Syntax

public virtual System.Threading.Tasks.Task AuthenticateAsClientAsync (string targetHost, System.Security.Cryptography.X509Certificates.X509CertificateCollection clientCertificates, System.Security.Authentication.SslProtocols enabledSslProtocols, bool checkCertificateRevocation)

Parameters

targetHost
The name of the server that will share this System.Net.Security.SslStream.
clientCertificates
The System.Security.Cryptography.X509Certificates.X509CertificateCollection that contains client certificates.
enabledSslProtocols
The System.Security.Authentication.SslProtocols value that represents the protocol used for authentication.
checkCertificateRevocation
A bool value that specifies whether the certificate revocation list is checked during authentication.

Returns

Returns System.Threading.Tasks.Task

The task object representing the asynchronous operation.

Remarks

When authentication succeeds, you must check the SslStream.IsEncrypted and SslStream.IsSigned properties to determine what security services are used by the System.Net.Security.SslStream. Check the SslStream.IsMutuallyAuthenticated property to determine whether mutual authentication occurred.

If the authentication fails, you receive a System.Security.Authentication.AuthenticationException, and this System.Net.Security.SslStream is no longer useable. You should close this object and remove all references to it so that it can be collected by the garbage collector.

Note:

Client certificates are not supported in the SSL version 2 protocol.

Requirements

Namespace: System.Net.Security
Assembly: System (in System.dll)
Assembly Versions: 4.0.0.0
Since: .NET 2.0