SslStream.AuthenticateAsClientAsync SslStream.AuthenticateAsClientAsync SslStream.AuthenticateAsClientAsync SslStream.AuthenticateAsClientAsync Method

Definition

Authenticate the client side of a client-server connection as an asynchronous operation.

Overloads

AuthenticateAsClientAsync(String) AuthenticateAsClientAsync(String) AuthenticateAsClientAsync(String) AuthenticateAsClientAsync(String)

Called by clients to authenticate the server and optionally the client in a client-server connection as an asynchronous operation.

AuthenticateAsClientAsync(SslClientAuthenticationOptions, CancellationToken) AuthenticateAsClientAsync(SslClientAuthenticationOptions, CancellationToken) AuthenticateAsClientAsync(SslClientAuthenticationOptions, CancellationToken)
AuthenticateAsClientAsync(String, X509CertificateCollection, Boolean) AuthenticateAsClientAsync(String, X509CertificateCollection, Boolean) AuthenticateAsClientAsync(String, X509CertificateCollection, Boolean) AuthenticateAsClientAsync(String, X509CertificateCollection, Boolean)

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 the system default SSL protocol.

AuthenticateAsClientAsync(String, X509CertificateCollection, SslProtocols, Boolean) AuthenticateAsClientAsync(String, X509CertificateCollection, SslProtocols, Boolean) AuthenticateAsClientAsync(String, X509CertificateCollection, SslProtocols, Boolean) AuthenticateAsClientAsync(String, X509CertificateCollection, SslProtocols, Boolean)

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.

AuthenticateAsClientAsync(String) AuthenticateAsClientAsync(String) AuthenticateAsClientAsync(String) AuthenticateAsClientAsync(String)

Called by clients to authenticate the server and optionally the client in a client-server connection as an asynchronous operation.

public:
 virtual System::Threading::Tasks::Task ^ AuthenticateAsClientAsync(System::String ^ targetHost);
public virtual System.Threading.Tasks.Task AuthenticateAsClientAsync (string targetHost);
abstract member AuthenticateAsClientAsync : string -> System.Threading.Tasks.Task
override this.AuthenticateAsClientAsync : string -> System.Threading.Tasks.Task
Public Overridable Function AuthenticateAsClientAsync (targetHost As String) As Task

Parameters

targetHost
String String String String

The name of the server that shares this SslStream.

Returns

The task object representing the asynchronous operation.

Exceptions

The authentication failed and left this object in an unusable state.

Authentication has already occurred.

-or-

Server authentication using this SslStream was tried previously.

-or-

Authentication is already in progress.

Remarks

Starting with .NET Framework 4.7, this method authenticates using None, which allows the operating system to choose the best protocol to use, and to block protocols that are not secure. In .NET Framework 4.6 (and .NET Framework 4.5 with the latest security patches installed), the allowed TLS/SSL protocols versions are 1.2, 1.1, and 1.0 (unless you disable strong cryptography by editing the Windows Registry). 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 IsEncrypted and IsSigned properties to determine what security services are used by the SslStream. Check the IsMutuallyAuthenticated property to determine whether mutual authentication occurred.

If the authentication fails, you receive a AuthenticationException, and this 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.

AuthenticateAsClientAsync(SslClientAuthenticationOptions, CancellationToken) AuthenticateAsClientAsync(SslClientAuthenticationOptions, CancellationToken) AuthenticateAsClientAsync(SslClientAuthenticationOptions, CancellationToken)

public:
 System::Threading::Tasks::Task ^ AuthenticateAsClientAsync(System::Net::Security::SslClientAuthenticationOptions ^ sslClientAuthenticationOptions, System::Threading::CancellationToken cancellationToken);
public System.Threading.Tasks.Task AuthenticateAsClientAsync (System.Net.Security.SslClientAuthenticationOptions sslClientAuthenticationOptions, System.Threading.CancellationToken cancellationToken = null);
member this.AuthenticateAsClientAsync : System.Net.Security.SslClientAuthenticationOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task

Parameters

Returns

AuthenticateAsClientAsync(String, X509CertificateCollection, Boolean) AuthenticateAsClientAsync(String, X509CertificateCollection, Boolean) AuthenticateAsClientAsync(String, X509CertificateCollection, Boolean) AuthenticateAsClientAsync(String, X509CertificateCollection, Boolean)

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 the system default SSL protocol.

public:
 virtual System::Threading::Tasks::Task ^ AuthenticateAsClientAsync(System::String ^ targetHost, System::Security::Cryptography::X509Certificates::X509CertificateCollection ^ clientCertificates, bool checkCertificateRevocation);
public virtual System.Threading.Tasks.Task AuthenticateAsClientAsync (string targetHost, System.Security.Cryptography.X509Certificates.X509CertificateCollection clientCertificates, bool checkCertificateRevocation);
abstract member AuthenticateAsClientAsync : string * System.Security.Cryptography.X509Certificates.X509CertificateCollection * bool -> System.Threading.Tasks.Task
override this.AuthenticateAsClientAsync : string * System.Security.Cryptography.X509Certificates.X509CertificateCollection * bool -> System.Threading.Tasks.Task
Public Overridable Function AuthenticateAsClientAsync (targetHost As String, clientCertificates As X509CertificateCollection, checkCertificateRevocation As Boolean) As Task

Parameters

targetHost
String String String String

The name of the server that will share this SslStream.

checkCertificateRevocation
Boolean Boolean Boolean Boolean

A Boolean value that specifies whether the certificate revocation list is checked during authentication.

Returns

The task object representing the asynchronous operation.

Remarks

Starting with .NET Framework 4.7, this method authenticates using None, which allows the operating system to choose the best protocol to use, and to block protocols that are not secure. In .NET Framework 4.6 (and .NET Framework 4.5 with the latest security patches installed), the allowed TLS/SSL protocols versions are 1.2, 1.1, and 1.0 (unless you disable strong cryptography by editing the Windows Registry).

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

If the authentication fails, you receive a AuthenticationException, and this 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.

AuthenticateAsClientAsync(String, X509CertificateCollection, SslProtocols, Boolean) AuthenticateAsClientAsync(String, X509CertificateCollection, SslProtocols, Boolean) AuthenticateAsClientAsync(String, X509CertificateCollection, SslProtocols, Boolean) AuthenticateAsClientAsync(String, X509CertificateCollection, SslProtocols, Boolean)

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.

public:
 virtual System::Threading::Tasks::Task ^ AuthenticateAsClientAsync(System::String ^ targetHost, System::Security::Cryptography::X509Certificates::X509CertificateCollection ^ clientCertificates, System::Security::Authentication::SslProtocols enabledSslProtocols, bool checkCertificateRevocation);
public virtual System.Threading.Tasks.Task AuthenticateAsClientAsync (string targetHost, System.Security.Cryptography.X509Certificates.X509CertificateCollection clientCertificates, System.Security.Authentication.SslProtocols enabledSslProtocols, bool checkCertificateRevocation);
abstract member AuthenticateAsClientAsync : string * System.Security.Cryptography.X509Certificates.X509CertificateCollection * System.Security.Authentication.SslProtocols * bool -> System.Threading.Tasks.Task
override this.AuthenticateAsClientAsync : string * System.Security.Cryptography.X509Certificates.X509CertificateCollection * System.Security.Authentication.SslProtocols * bool -> System.Threading.Tasks.Task
Public Overridable Function AuthenticateAsClientAsync (targetHost As String, clientCertificates As X509CertificateCollection, enabledSslProtocols As SslProtocols, checkCertificateRevocation As Boolean) As Task

Parameters

targetHost
String String String String

The name of the server that will share this SslStream.

enabledSslProtocols
SslProtocols SslProtocols SslProtocols SslProtocols

The SslProtocols value that represents the protocol used for authentication.

checkCertificateRevocation
Boolean Boolean Boolean Boolean

A Boolean value that specifies whether the certificate revocation list is checked during authentication.

Returns

The task object representing the asynchronous operation.

Remarks

Starting with .NET Framework 4.7, this method authenticates using None, which allows the operating system to choose the best protocol to use, and to block protocols that are not secure. In .NET Framework 4.6 (and .NET Framework 4.5 with the latest security patches installed), the allowed TLS/SSL protocols versions are 1.2, 1.1, and 1.0 (unless you disable strong cryptography by editing the Windows Registry).

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

If the authentication fails, you receive a AuthenticationException, and this 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.

Applies to