SslStream.AuthenticateAsServerAsync 方法
定义
服务器调用此方法,对客户端-服务器连接中的服务器及客户端(可选)进行身份验证以作为异步操作。Called by servers to authenticate the server and optionally the client in a client-server connection as an asynchronous operation.
重载
| 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. 身份验证过程使用 |
| 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. 身份验证过程使用 |
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.
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
参数
- serverCertificate
- X509Certificate
用于对服务器进行身份验证的 X509Certificate 。The X509Certificate used to authenticate the server.
- clientCertificateRequired
- Boolean
一个 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
SslProtocols 值,该值表示进行身份验证所使用的协议。The SslProtocols value that represents protocols used for authentication.
- checkCertificateRevocation
- Boolean
一个 Boolean 值,该值指定身份验证期间是否检查证书吊销列表。A Boolean value that specifies whether the certificate revocation list is checked during authentication.
返回
表示异步操作的任务对象。The task object representing the asynchronous operation.
例外
serverCertificate 为 null。serverCertificate is null.
身份验证失败,并使此对象处于不可用的状态。The authentication failed and left this object in an unusable state.
已进行了身份验证。Authentication has already occurred.
或-or- 之前已尝试使用此 SslStream 进行了客户端身份验证。Client authentication using this SslStream was tried previously.
或-or- 身份验证已在进行中。Authentication is already in progress.
此对象已关闭。This object has been closed.
注解
从 .NET Framework 4.7 开始,此方法使用 None 进行身份验证,这允许操作系统选择要使用的最佳协议,并将其用于阻止不安全的协议。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. 在 .NET Framework 4.6(以及安装了最新安全修补程序的 .NET Framework 4.5)中,允许的 TLS/SSL 协议版本为 1.2、1.1 和 1.0(除非通过编辑 Windows 注册表禁用强加密)。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).
如果身份验证失败,则会收到 AuthenticationException ,此 SslStream 操作不再可用。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.
适用于
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.
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
参数
- serverCertificate
- X509Certificate
用于对服务器进行身份验证的 X509Certificate 。The X509Certificate used to authenticate the server.
- clientCertificateRequired
- Boolean
一个 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
一个 Boolean 值,该值指定身份验证期间是否检查证书吊销列表。A Boolean value that specifies whether the certificate revocation list is checked during authentication.
返回
表示异步操作的任务对象。The task object representing the asynchronous operation.
例外
serverCertificate 为 null。serverCertificate is null.
身份验证失败,并使此对象处于不可用的状态。The authentication failed and left this object in an unusable state.
已进行了身份验证。Authentication has already occurred.
或-or- 之前已尝试使用此 SslStream 进行了客户端身份验证。Client authentication using this SslStream was tried previously.
或-or- 身份验证已在进行中。Authentication is already in progress.
此对象已关闭。This object has been closed.
注解
从 .NET Framework 4.7 开始,此方法使用 None 进行身份验证,这允许操作系统选择要使用的最佳协议,并将其用于阻止不安全的协议。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. 在 .NET Framework 4.6(以及安装了最新安全修补程序的 .NET Framework 4.5)中,允许的 TLS/SSL 协议版本为 1.2、1.1 和 1.0(除非通过编辑 Windows 注册表禁用强加密)。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).
如果身份验证失败,则会收到 AuthenticationException ,此 SslStream 操作不再可用。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.
适用于
AuthenticateAsServerAsync(SslServerAuthenticationOptions, CancellationToken)
服务器调用此方法,对客户端-服务器连接中的服务器及客户端(可选)进行身份验证以作为异步操作。Called by servers to authenticate the server and optionally the client in a client-server connection as an asynchronous operation. 身份验证过程使用 sslClientAuthenticationOptions 属性包中指定的信息。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
参数
- sslServerAuthenticationOptions
- SslServerAuthenticationOptions
SSL 连接的属性包。The property bag for the SSL connection.
- cancellationToken
- CancellationToken
要监视取消请求的标记。The token to monitor for cancellation requests.
返回
表示异步操作的任务对象。The task object representing the asynchronous operation.
例外
ServerCertificateSelectionCallback 或 ServerCertificate 或 ServerCertificateContext 为 null,并且未在 SslStream 构造函数中设置 LocalCertificateSelectionCallback。Either ServerCertificateSelectionCallback or ServerCertificate or ServerCertificateContext is null and LocalCertificateSelectionCallback is not set in the SslStream constructor.
sslServerAuthenticationOptions 为 null。sslServerAuthenticationOptions is null.
身份验证失败,并使此对象处于不可用的状态。The authentication failed and left this object in an unusable state.
已进行了身份验证。Authentication has already occurred.
或-or- 之前已尝试使用此 SslStream 进行了客户端身份验证。Client authentication using this SslStream was tried previously.
或-or- 身份验证已在进行中。Authentication is already in progress.
此对象已关闭。This object has been closed.
注解
如果身份验证失败,则会收到 AuthenticationException ,此 SslStream 操作不再可用。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.
适用于
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.
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
参数
- serverCertificate
- X509Certificate
用于对服务器进行身份验证的证书。The certificate used to authenticate the server.
返回
表示异步操作的任务对象。The task object representing the asynchronous operation.
例外
serverCertificate 为 null。serverCertificate is null.
身份验证失败,并使此对象处于不可用的状态。The authentication failed and left this object in an unusable state.
已进行了身份验证。Authentication has already occurred.
或-or- 之前已尝试使用此 SslStream 进行了客户端身份验证。Client authentication using this SslStream was tried previously.
或-or- 身份验证已在进行中。Authentication is already in progress.
此对象已关闭。This object has been closed.
注解
从 .NET Framework 4.7 开始,此方法使用 None 进行身份验证,这允许操作系统选择要使用的最佳协议,并将其用于阻止不安全的协议。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. 在 .NET Framework 4.6(以及安装了最新安全修补程序的 .NET Framework 4.5)中,允许的 TLS/SSL 协议版本为 1.2、1.1 和 1.0(除非通过编辑 Windows 注册表禁用强加密)。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).
此方法使用进行身份验证 Default 。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.
如果身份验证失败,则会收到 AuthenticationException ,此 SslStream 操作不再可用。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.
适用于
AuthenticateAsServerAsync(ServerOptionsSelectionCallback, Object, CancellationToken)
服务器调用此方法,对客户端-服务器连接中的服务器及客户端(可选)进行身份验证以作为异步操作。Called by servers to authenticate the server and optionally the client in a client-server connection as an asynchronous operation. 身份验证过程使用 optionsCallback 返回的信息。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
参数
- optionsCallback
- ServerOptionsSelectionCallback
回调委托。The callback delegate.
- state
- Object
要在调用回调时传递给 optionsCallback 的状态对象。The state object to pass to optionsCallback when the callback is invoked.
- cancellationToken
- CancellationToken
要监视取消请求的标记。The token to monitor for cancellation requests.
返回
表示异步操作的任务对象。The task object representing the asynchronous operation.
例外
ServerCertificateSelectionCallback 或 ServerCertificate 或 ServerCertificateContext 为 null,并且未在 SslStream 构造函数中设置 LocalCertificateSelectionCallback。Either ServerCertificateSelectionCallback or ServerCertificate or ServerCertificateContext is null and LocalCertificateSelectionCallback is not set in the SslStream constructor.
身份验证失败,并使此对象处于不可用的状态。The authentication failed and left this object in an unusable state.
已进行了身份验证。Authentication has already occurred.
或-or- 之前已尝试使用此 SslStream 进行了客户端身份验证。Client authentication using this SslStream was tried previously.
或-or- 身份验证已在进行中。Authentication is already in progress.
此对象已关闭。This object has been closed.
注解
如果身份验证失败,则会收到 AuthenticationException ,此 SslStream 操作不再可用。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.