Breyta

Deila með


SslStream.AuthenticateAsServerAsync Method

Definition

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

Overloads

AuthenticateAsServerAsync(X509Certificate, Boolean, SslProtocols, Boolean)

Called by servers to authenticate the server and optionally the client in a client-server connection using the specified certificates, requirements and security protocol as an asynchronous operation.

AuthenticateAsServerAsync(X509Certificate, Boolean, Boolean)

Called by servers to authenticate the server and optionally the client in a client-server connection using the specified certificates, requirements and security protocol as an asynchronous operation.

AuthenticateAsServerAsync(SslServerAuthenticationOptions, CancellationToken)

Called by servers to authenticate the server and optionally the client in a client-server connection as an asynchronous operation. The authentication process uses information specified in the sslClientAuthenticationOptions property bag.

AuthenticateAsServerAsync(X509Certificate)

Called by servers to authenticate the server and optionally the client in a client-server connection using the specified certificate as an asynchronous operation.

AuthenticateAsServerAsync(ServerOptionsSelectionCallback, Object, CancellationToken)

Called by servers to authenticate the server and optionally the client in a client-server connection as an asynchronous operation. The authentication process uses information returned by optionsCallback.

AuthenticateAsServerAsync(X509Certificate, Boolean, SslProtocols, Boolean)

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

Called by servers to authenticate the server and optionally the client in a client-server connection using the specified certificates, requirements and security protocol as an asynchronous operation.

public:
 virtual System::Threading::Tasks::Task ^ AuthenticateAsServerAsync(System::Security::Cryptography::X509Certificates::X509Certificate ^ serverCertificate, bool clientCertificateRequired, System::Security::Authentication::SslProtocols enabledSslProtocols, bool checkCertificateRevocation);
public virtual System.Threading.Tasks.Task AuthenticateAsServerAsync (System.Security.Cryptography.X509Certificates.X509Certificate serverCertificate, bool clientCertificateRequired, System.Security.Authentication.SslProtocols enabledSslProtocols, bool checkCertificateRevocation);
abstract member AuthenticateAsServerAsync : System.Security.Cryptography.X509Certificates.X509Certificate * bool * System.Security.Authentication.SslProtocols * bool -> System.Threading.Tasks.Task
override this.AuthenticateAsServerAsync : System.Security.Cryptography.X509Certificates.X509Certificate * bool * System.Security.Authentication.SslProtocols * bool -> System.Threading.Tasks.Task
Public Overridable Function AuthenticateAsServerAsync (serverCertificate As X509Certificate, clientCertificateRequired As Boolean, enabledSslProtocols As SslProtocols, checkCertificateRevocation As Boolean) As Task

Parameters

serverCertificate
X509Certificate

The X509Certificate used to authenticate the server.

clientCertificateRequired
Boolean

A Boolean value that specifies whether the client is asked for a certificate for authentication. Note that this is only a request -- if no certificate is provided, the server still accepts the connection request.

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.

Returns

The task object representing the asynchronous operation.

Exceptions

serverCertificate is null.

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

Authentication has already occurred.

-or-

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

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.

This method stores in the task it returns all non-usage exceptions that the method's synchronous counterpart can throw. If an exception is stored into the returned task, that exception will be thrown when the task is awaited. Usage exceptions, such as ArgumentException, are still thrown synchronously. For the stored exceptions, see the exceptions thrown by AuthenticateAsServer(X509Certificate, Boolean, SslProtocols, Boolean).

Applies to

AuthenticateAsServerAsync(X509Certificate, Boolean, Boolean)

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

Called by servers to authenticate the server and optionally the client in a client-server connection using the specified certificates, requirements and security protocol as an asynchronous operation.

public:
 virtual System::Threading::Tasks::Task ^ AuthenticateAsServerAsync(System::Security::Cryptography::X509Certificates::X509Certificate ^ serverCertificate, bool clientCertificateRequired, bool checkCertificateRevocation);
public virtual System.Threading.Tasks.Task AuthenticateAsServerAsync (System.Security.Cryptography.X509Certificates.X509Certificate serverCertificate, bool clientCertificateRequired, bool checkCertificateRevocation);
abstract member AuthenticateAsServerAsync : System.Security.Cryptography.X509Certificates.X509Certificate * bool * bool -> System.Threading.Tasks.Task
override this.AuthenticateAsServerAsync : System.Security.Cryptography.X509Certificates.X509Certificate * bool * bool -> System.Threading.Tasks.Task
Public Overridable Function AuthenticateAsServerAsync (serverCertificate As X509Certificate, clientCertificateRequired As Boolean, checkCertificateRevocation As Boolean) As Task

Parameters

serverCertificate
X509Certificate

The X509Certificate used to authenticate the server.

clientCertificateRequired
Boolean

A Boolean value that specifies whether the client is asked for a certificate for authentication. Note that this is only a request -- if no certificate is provided, the server still accepts the connection request.

checkCertificateRevocation
Boolean

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

Returns

The task object representing the asynchronous operation.

Exceptions

serverCertificate is null.

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

Authentication has already occurred.

-or-

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

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.

This method stores in the task it returns all non-usage exceptions that the method's synchronous counterpart can throw. If an exception is stored into the returned task, that exception will be thrown when the task is awaited. Usage exceptions, such as ArgumentException, are still thrown synchronously. For the stored exceptions, see the exceptions thrown by AuthenticateAsServer(X509Certificate, Boolean, Boolean).

Applies to

AuthenticateAsServerAsync(SslServerAuthenticationOptions, CancellationToken)

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

Called by servers to authenticate the server and optionally the client in a client-server connection as an asynchronous operation. The authentication process uses information specified in the sslClientAuthenticationOptions property bag.

public:
 System::Threading::Tasks::Task ^ AuthenticateAsServerAsync(System::Net::Security::SslServerAuthenticationOptions ^ sslServerAuthenticationOptions, System::Threading::CancellationToken cancellationToken);
public System.Threading.Tasks.Task AuthenticateAsServerAsync (System.Net.Security.SslServerAuthenticationOptions sslServerAuthenticationOptions, System.Threading.CancellationToken cancellationToken = default);
public System.Threading.Tasks.Task AuthenticateAsServerAsync (System.Net.Security.SslServerAuthenticationOptions sslServerAuthenticationOptions, System.Threading.CancellationToken cancellationToken);
member this.AuthenticateAsServerAsync : System.Net.Security.SslServerAuthenticationOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task
Public Function AuthenticateAsServerAsync (sslServerAuthenticationOptions As SslServerAuthenticationOptions, Optional cancellationToken As CancellationToken = Nothing) As Task
Public Function AuthenticateAsServerAsync (sslServerAuthenticationOptions As SslServerAuthenticationOptions, cancellationToken As CancellationToken) As Task

Parameters

sslServerAuthenticationOptions
SslServerAuthenticationOptions

The property bag for the SSL connection.

cancellationToken
CancellationToken

The token to monitor for cancellation requests.

Returns

The task object representing the asynchronous operation.

Exceptions

sslServerAuthenticationOptions is null.

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

Authentication has already occurred.

-or-

Client authentication using this SslStream was tried previously.

-or-

Authentication is already in progress.

This object has been closed.

The cancellation token was canceled. This exception is stored into the returned task.

Remarks

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.

This method stores in the task it returns all non-usage exceptions that the method's synchronous counterpart can throw. If an exception is stored into the returned task, that exception will be thrown when the task is awaited. Usage exceptions, such as ArgumentException, are still thrown synchronously. For the stored exceptions, see the exceptions thrown by AuthenticateAsServer(SslServerAuthenticationOptions).

Applies to

AuthenticateAsServerAsync(X509Certificate)

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

Called by servers to authenticate the server and optionally the client in a client-server connection using the specified certificate as an asynchronous operation.

public:
 virtual System::Threading::Tasks::Task ^ AuthenticateAsServerAsync(System::Security::Cryptography::X509Certificates::X509Certificate ^ serverCertificate);
public virtual System.Threading.Tasks.Task AuthenticateAsServerAsync (System.Security.Cryptography.X509Certificates.X509Certificate serverCertificate);
abstract member AuthenticateAsServerAsync : System.Security.Cryptography.X509Certificates.X509Certificate -> System.Threading.Tasks.Task
override this.AuthenticateAsServerAsync : System.Security.Cryptography.X509Certificates.X509Certificate -> System.Threading.Tasks.Task
Public Overridable Function AuthenticateAsServerAsync (serverCertificate As X509Certificate) As Task

Parameters

serverCertificate
X509Certificate

The certificate used to authenticate the server.

Returns

The task object representing the asynchronous operation.

Exceptions

serverCertificate is null.

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

Authentication has already occurred.

-or-

Client authentication using this SslStream was tried previously.

-or-

Authentication is already in progress.

This object has been closed.

The AuthenticateAsServerAsync method is not supported on Windows 95, Windows 98, or Windows Millennium.

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

This method authenticates using Default. The certificate revocation list is not checked during authentication. The client is not required to provide a certificate for authentication.

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.

This method stores in the task it returns all non-usage exceptions that the method's synchronous counterpart can throw. If an exception is stored into the returned task, that exception will be thrown when the task is awaited. Usage exceptions, such as ArgumentException, are still thrown synchronously. For the stored exceptions, see the exceptions thrown by AuthenticateAsServer(X509Certificate).

Applies to

AuthenticateAsServerAsync(ServerOptionsSelectionCallback, Object, CancellationToken)

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

Called by servers to authenticate the server and optionally the client in a client-server connection as an asynchronous operation. The authentication process uses information returned by optionsCallback.

public System.Threading.Tasks.Task AuthenticateAsServerAsync (System.Net.Security.ServerOptionsSelectionCallback optionsCallback, object? state, System.Threading.CancellationToken cancellationToken = default);
member this.AuthenticateAsServerAsync : System.Net.Security.ServerOptionsSelectionCallback * obj * System.Threading.CancellationToken -> System.Threading.Tasks.Task
Public Function AuthenticateAsServerAsync (optionsCallback As ServerOptionsSelectionCallback, state As Object, Optional cancellationToken As CancellationToken = Nothing) As Task

Parameters

optionsCallback
ServerOptionsSelectionCallback

The callback delegate.

state
Object

The state object to pass to optionsCallback when the callback is invoked.

cancellationToken
CancellationToken

The token to monitor for cancellation requests.

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-

Client authentication using this SslStream was tried previously.

-or-

Authentication is already in progress.

This object has been closed.

The cancellation token was canceled. This exception is stored into the returned task.

Remarks

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.

Applies to