SslStream.AuthenticateAsServerAsync 方法

定义

由服务器调用,以将服务器和客户端-服务器连接中的客户端作为异步操作进行身份验证。

重载

名称 说明
AuthenticateAsServerAsync(X509Certificate, Boolean, SslProtocols, Boolean)

由服务器调用,以使用指定的证书、要求和安全协议作为异步操作在客户端-服务器连接中对服务器和客户端进行身份验证。

AuthenticateAsServerAsync(X509Certificate, Boolean, Boolean)

由服务器调用,以使用指定的证书、要求和安全协议作为异步操作在客户端-服务器连接中对服务器和客户端进行身份验证。

AuthenticateAsServerAsync(X509Certificate)

由服务器调用,以使用指定的证书作为异步操作在客户端-服务器连接中对服务器和客户端进行身份验证。

AuthenticateAsServerAsync(SslServerAuthenticationOptions, CancellationToken)

将服务器和客户端-服务器连接中的客户端作为异步操作进行身份验证(可选)。 身份验证过程使用属性包中指定的 sslServerAuthenticationOptions 信息。

AuthenticateAsServerAsync(X509Certificate, Boolean, SslProtocols, Boolean)

由服务器调用,以使用指定的证书、要求和安全协议作为异步操作在客户端-服务器连接中对服务器和客户端进行身份验证。

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。

clientCertificateRequired
Boolean

一个 Boolean 值,该值指定是否要求客户端进行身份验证。 请注意,这只是一个请求 -- 如果未提供证书,服务器仍接受连接请求。

enabledSslProtocols
SslProtocols

表示 SslProtocols 用于身份验证的协议的值。

checkCertificateRevocation
Boolean

一个 Boolean 值,该值指定在身份验证期间是否检查证书吊销列表。

返回

表示异步操作的任务对象。

例外

serverCertificatenull

身份验证失败,并且使此对象处于不可用状态。

身份验证已发生。

-或-

以前已尝试过使用此 SslStream 身份验证的客户端身份验证。

-或-

身份验证正在进行中。

此对象已关闭。

注解

从 .NET Framework 4.7 开始,此方法使用 None此方法进行身份验证,这样操作系统就可以选择要使用的最佳协议,并阻止不安全的协议。 在安装了最新安全修补程序的 .NET Framework 4.6 和 .NET Framework 4.5 中,允许的 TLS/SSL 协议版本为 1.2、1.1 和 1.0(除非通过编辑 Windows 注册表禁用强加密)。

如果身份验证失败,则会收到一个 AuthenticationException,这 SslStream 不再可用。 应关闭此对象并删除对该对象的所有引用,以便垃圾回收器可以收集它。

此方法存储在任务中,它返回该方法的同步对应项可以引发的所有非使用异常。 如果异常存储在返回的任务中,则等待任务时将引发该异常。 使用情况异常(例如 ArgumentException)仍会同步引发。 有关存储的异常,请参阅由 AuthenticateAsServer(X509Certificate, Boolean, SslProtocols, Boolean)..

适用于

AuthenticateAsServerAsync(X509Certificate, Boolean, Boolean)

由服务器调用,以使用指定的证书、要求和安全协议作为异步操作在客户端-服务器连接中对服务器和客户端进行身份验证。

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。

clientCertificateRequired
Boolean

一个 Boolean 值,该值指定是否要求客户端进行身份验证。 请注意,这只是一个请求 -- 如果未提供证书,服务器仍接受连接请求。

checkCertificateRevocation
Boolean

一个 Boolean 值,该值指定在身份验证期间是否检查证书吊销列表。

返回

表示异步操作的任务对象。

例外

serverCertificatenull

身份验证失败,并且使此对象处于不可用状态。

身份验证已发生。

-或-

以前已尝试过使用此 SslStream 身份验证的客户端身份验证。

-或-

身份验证正在进行中。

此对象已关闭。

注解

从 .NET Framework 4.7 开始,此方法使用 None此方法进行身份验证,这样操作系统就可以选择要使用的最佳协议,并阻止不安全的协议。 在安装了最新安全修补程序的 .NET Framework 4.6 和 .NET Framework 4.5 中,允许的 TLS/SSL 协议版本为 1.2、1.1 和 1.0(除非通过编辑 Windows 注册表禁用强加密)。

如果身份验证失败,则会收到一个 AuthenticationException,这 SslStream 不再可用。 应关闭此对象并删除对该对象的所有引用,以便垃圾回收器可以收集它。

此方法存储在任务中,它返回该方法的同步对应项可以引发的所有非使用异常。 如果异常存储在返回的任务中,则等待任务时将引发该异常。 使用情况异常(例如 ArgumentException)仍会同步引发。 有关存储的异常,请参阅由 AuthenticateAsServer(X509Certificate, Boolean, Boolean)..

适用于

AuthenticateAsServerAsync(X509Certificate)

由服务器调用,以使用指定的证书作为异步操作在客户端-服务器连接中对服务器和客户端进行身份验证。

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

用于对服务器进行身份验证的证书。

返回

表示异步操作的任务对象。

例外

serverCertificatenull

身份验证失败,并且使此对象处于不可用状态。

身份验证已发生。

-或-

以前已尝试过使用此 SslStream 身份验证的客户端身份验证。

-或-

身份验证正在进行中。

此对象已关闭。

Windows 95、Windows 98 或千年Windows不支持 AuthenticateAsServerAsync 方法。

注解

从 .NET Framework 4.7 开始,此方法使用 None此方法进行身份验证,这样操作系统就可以选择要使用的最佳协议,并阻止不安全的协议。 在安装了最新安全修补程序的 .NET Framework 4.6 和 .NET Framework 4.5 中,允许的 TLS/SSL 协议版本为 1.2、1.1 和 1.0(除非通过编辑 Windows 注册表禁用强加密)。

此方法使用 Default. 身份验证期间不会检查证书吊销列表。 客户端不需要提供用于身份验证的证书。

如果身份验证失败,则会收到一个 AuthenticationException,这 SslStream 不再可用。 应关闭此对象并删除对该对象的所有引用,以便垃圾回收器可以收集它。

此方法存储在任务中,它返回该方法的同步对应项可以引发的所有非使用异常。 如果异常存储在返回的任务中,则等待任务时将引发该异常。 使用情况异常(例如 ArgumentException)仍会同步引发。 有关存储的异常,请参阅由 AuthenticateAsServer(X509Certificate)..

适用于

AuthenticateAsServerAsync(SslServerAuthenticationOptions, CancellationToken)

将服务器和客户端-服务器连接中的客户端作为异步操作进行身份验证(可选)。 身份验证过程使用属性包中指定的 sslServerAuthenticationOptions 信息。

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);
member this.AuthenticateAsServerAsync : System.Net.Security.SslServerAuthenticationOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task
Public Function AuthenticateAsServerAsync (sslServerAuthenticationOptions As SslServerAuthenticationOptions, cancellationToken As CancellationToken) As Task

参数

sslServerAuthenticationOptions
SslServerAuthenticationOptions

SSL 连接的属性包。

cancellationToken
CancellationToken

用于监视取消请求的令牌。

返回

表示异步操作的任务对象。

例外

sslServerAuthenticationOptionsnull

身份验证失败,并且使此对象处于不可用状态。

身份验证已发生。

-或-

以前已尝试过使用此 SslStream 身份验证的客户端身份验证。

-或-

身份验证正在进行中。

此对象已关闭。

取消令牌已取消。 此异常存储在返回的任务中。

注解

如果身份验证失败,则会收到一个 AuthenticationException,这 SslStream 不再可用。 应关闭此对象并删除对该对象的所有引用,以便垃圾回收器可以收集它。

此方法存储在任务中,它返回该方法的同步对应项可以引发的所有非使用异常。 如果异常存储在返回的任务中,则等待任务时将引发该异常。 使用情况异常(例如 ArgumentException)仍会同步引发。 有关存储的异常,请参阅由 AuthenticateAsServer(SslServerAuthenticationOptions)..

适用于