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.

Syntax

public virtual System.Threading.Tasks.Task AuthenticateAsClientAsync (string targetHost)

Parameters

targetHost
The name of the server that shares this System.Net.Security.SslStream.

Returns

Returns System.Threading.Tasks.Task

The task object representing the asynchronous operation.

Remarks

This method authenticates using System.Security.Authentication.SslProtocols.Default. No client certificates are used in the authentication. The certificate revocation list is not checked during authentication. The value specified for targetHost must match the name on the server's certificate.

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.

Requirements

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