संपादित करें

इसके माध्यम से साझा किया गया


SslStream.BeginAuthenticateAsClient Method

Definition

Begins an operation to authenticate the client side of a client-server connection.

Overloads

BeginAuthenticateAsClient(String, AsyncCallback, Object)

Called by clients to begin an asynchronous operation to authenticate the server and optionally the client.

BeginAuthenticateAsClient(String, X509CertificateCollection, Boolean, AsyncCallback, Object)

Called by clients to begin an asynchronous operation to authenticate the server and optionally the client using the specified certificates and the system default security protocol.

BeginAuthenticateAsClient(String, X509CertificateCollection, SslProtocols, Boolean, AsyncCallback, Object)

Called by clients to begin an asynchronous operation to authenticate the server and optionally the client using the specified certificates and security protocol.

Remarks

The overloads of this method do not block while authentication is in progress. To block while waiting for the authentication to complete, use one of the AuthenticateAsClient methods.

BeginAuthenticateAsClient(String, AsyncCallback, Object)

Source:
SslStream.cs
Source:
SslStream.cs
Source:
SslStream.cs

Called by clients to begin an asynchronous operation to authenticate the server and optionally the client.

public:
 virtual IAsyncResult ^ BeginAuthenticateAsClient(System::String ^ targetHost, AsyncCallback ^ asyncCallback, System::Object ^ asyncState);
public virtual IAsyncResult BeginAuthenticateAsClient (string targetHost, AsyncCallback? asyncCallback, object? asyncState);
public virtual IAsyncResult BeginAuthenticateAsClient (string targetHost, AsyncCallback asyncCallback, object asyncState);
abstract member BeginAuthenticateAsClient : string * AsyncCallback * obj -> IAsyncResult
override this.BeginAuthenticateAsClient : string * AsyncCallback * obj -> IAsyncResult
Public Overridable Function BeginAuthenticateAsClient (targetHost As String, asyncCallback As AsyncCallback, asyncState As Object) As IAsyncResult

Parameters

targetHost
String

The name of the server that shares this SslStream.

asyncCallback
AsyncCallback

An AsyncCallback delegate that references the method to invoke when the authentication is complete.

asyncState
Object

A user-defined object that contains information about the operation. This object is passed to the asyncCallback delegate when the operation completes.

Returns

An IAsyncResult object that indicates the status of the asynchronous operation.

Exceptions

targetHost is null.

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.

This object has been closed.

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.

The asynchronous authentication operation must be completed by calling the EndAuthenticateAsClient method. Typically, the method is invoked by the asyncCallback delegate.

This method does not block while the operation completes. To block until the operation completes, use one of the AuthenticateAsClient method overloads.

For detailed information about using the asynchronous programming model, see Calling Synchronous Methods Asynchronously

If you receive a AuthenticationException, 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.

Applies to

BeginAuthenticateAsClient(String, X509CertificateCollection, Boolean, AsyncCallback, Object)

Source:
SslStream.cs
Source:
SslStream.cs
Source:
SslStream.cs

Called by clients to begin an asynchronous operation to authenticate the server and optionally the client using the specified certificates and the system default security protocol.

public:
 virtual IAsyncResult ^ BeginAuthenticateAsClient(System::String ^ targetHost, System::Security::Cryptography::X509Certificates::X509CertificateCollection ^ clientCertificates, bool checkCertificateRevocation, AsyncCallback ^ asyncCallback, System::Object ^ asyncState);
public virtual IAsyncResult BeginAuthenticateAsClient (string targetHost, System.Security.Cryptography.X509Certificates.X509CertificateCollection? clientCertificates, bool checkCertificateRevocation, AsyncCallback? asyncCallback, object? asyncState);
public virtual IAsyncResult BeginAuthenticateAsClient (string targetHost, System.Security.Cryptography.X509Certificates.X509CertificateCollection clientCertificates, bool checkCertificateRevocation, AsyncCallback asyncCallback, object asyncState);
abstract member BeginAuthenticateAsClient : string * System.Security.Cryptography.X509Certificates.X509CertificateCollection * bool * AsyncCallback * obj -> IAsyncResult
override this.BeginAuthenticateAsClient : string * System.Security.Cryptography.X509Certificates.X509CertificateCollection * bool * AsyncCallback * obj -> IAsyncResult
Public Overridable Function BeginAuthenticateAsClient (targetHost As String, clientCertificates As X509CertificateCollection, checkCertificateRevocation As Boolean, asyncCallback As AsyncCallback, asyncState As Object) As IAsyncResult

Parameters

targetHost
String

The name of the server that shares this SslStream.

clientCertificates
X509CertificateCollection

The X509CertificateCollection containing client certificates.

checkCertificateRevocation
Boolean

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

asyncCallback
AsyncCallback

An AsyncCallback delegate that references the method to invoke when the authentication is complete.

asyncState
Object

A user-defined object that contains information about the operation. This object is passed to the asyncCallback delegate when the operation completes.

Returns

An IAsyncResult object that indicates the status of the asynchronous operation.

Exceptions

targetHost is null.

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.

This object has been closed.

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).

The value specified for targetHost must match the name on the server's certificate.

The asynchronous authentication operation must be completed by calling the EndAuthenticateAsClient method. Typically, the method is invoked by the asyncCallback delegate.

This method does not block while the operation completes. To block until the operation completes, use one of the AuthenticateAsClient method overloads.

For detailed information about using the asynchronous programming model, see Calling Synchronous Methods Asynchronously

If you receive a AuthenticationException, 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

BeginAuthenticateAsClient(String, X509CertificateCollection, SslProtocols, Boolean, AsyncCallback, Object)

Source:
SslStream.cs
Source:
SslStream.cs
Source:
SslStream.cs

Called by clients to begin an asynchronous operation to authenticate the server and optionally the client using the specified certificates and security protocol.

public:
 virtual IAsyncResult ^ BeginAuthenticateAsClient(System::String ^ targetHost, System::Security::Cryptography::X509Certificates::X509CertificateCollection ^ clientCertificates, System::Security::Authentication::SslProtocols enabledSslProtocols, bool checkCertificateRevocation, AsyncCallback ^ asyncCallback, System::Object ^ asyncState);
public virtual IAsyncResult BeginAuthenticateAsClient (string targetHost, System.Security.Cryptography.X509Certificates.X509CertificateCollection? clientCertificates, System.Security.Authentication.SslProtocols enabledSslProtocols, bool checkCertificateRevocation, AsyncCallback? asyncCallback, object? asyncState);
public virtual IAsyncResult BeginAuthenticateAsClient (string targetHost, System.Security.Cryptography.X509Certificates.X509CertificateCollection clientCertificates, System.Security.Authentication.SslProtocols enabledSslProtocols, bool checkCertificateRevocation, AsyncCallback asyncCallback, object asyncState);
abstract member BeginAuthenticateAsClient : string * System.Security.Cryptography.X509Certificates.X509CertificateCollection * System.Security.Authentication.SslProtocols * bool * AsyncCallback * obj -> IAsyncResult
override this.BeginAuthenticateAsClient : string * System.Security.Cryptography.X509Certificates.X509CertificateCollection * System.Security.Authentication.SslProtocols * bool * AsyncCallback * obj -> IAsyncResult
Public Overridable Function BeginAuthenticateAsClient (targetHost As String, clientCertificates As X509CertificateCollection, enabledSslProtocols As SslProtocols, checkCertificateRevocation As Boolean, asyncCallback As AsyncCallback, asyncState As Object) As IAsyncResult

Parameters

targetHost
String

The name of the server that shares this SslStream.

clientCertificates
X509CertificateCollection

The X509CertificateCollection containing client certificates.

enabledSslProtocols
SslProtocols

The SslProtocols value that represents protocols used for authentication.

checkCertificateRevocation
Boolean

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

asyncCallback
AsyncCallback

An AsyncCallback delegate that references the method to invoke when the authentication is complete.

asyncState
Object

A user-defined object that contains information about the operation. This object is passed to the asyncCallback delegate when the operation completes.

Returns

An IAsyncResult object that indicates the status of the asynchronous operation.

Exceptions

targetHost is null.

enabledSslProtocols is not a valid SslProtocols value.

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.

This object has been closed.

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).

The value specified for targetHost must match the name on the server's certificate.

The asynchronous authentication operation must be completed by calling the EndAuthenticateAsClient method. Typically, the method is invoked by the asyncCallback delegate.

This method does not block while the operation completes. To block until the operation completes, use one of the AuthenticateAsClient method overloads.

For detailed information about using the asynchronous programming model, see Calling Synchronous Methods Asynchronously

If you receive a AuthenticationException, 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