SslStream.BeginAuthenticateAsServer 方法

定義

開始非同步作業以處理驗證用戶端與伺服器連接的伺服器端。

多載

BeginAuthenticateAsServer(X509Certificate, AsyncCallback, Object)

由伺服器呼叫以開始非同步作業,驗證用戶端與伺服器連接中的用戶端及 (選擇性地驗證) 伺服器。

BeginAuthenticateAsServer(X509Certificate, Boolean, Boolean, AsyncCallback, Object)

已由伺服器呼叫來開始非同步作業,以使用指定的憑證、需求及系統預設安全性通訊協定來驗證伺服器和用戶端 (選擇性)。

BeginAuthenticateAsServer(X509Certificate, Boolean, SslProtocols, Boolean, AsyncCallback, Object)

已由伺服器呼叫來開始非同步作業,以使用指定的憑證、需求及安全性通訊協定來驗證伺服器和用戶端 (選擇性)。

備註

此方法的多載不會在進行驗證時封鎖。 若要在等候驗證完成時封鎖,請使用其中 AuthenticateAsServer 一種方法。

BeginAuthenticateAsServer(X509Certificate, AsyncCallback, Object)

來源:
SslStream.cs
來源:
SslStream.cs
來源:
SslStream.cs

由伺服器呼叫以開始非同步作業,驗證用戶端與伺服器連接中的用戶端及 (選擇性地驗證) 伺服器。

public:
 virtual IAsyncResult ^ BeginAuthenticateAsServer(System::Security::Cryptography::X509Certificates::X509Certificate ^ serverCertificate, AsyncCallback ^ asyncCallback, System::Object ^ asyncState);
public virtual IAsyncResult BeginAuthenticateAsServer (System.Security.Cryptography.X509Certificates.X509Certificate serverCertificate, AsyncCallback? asyncCallback, object? asyncState);
public virtual IAsyncResult BeginAuthenticateAsServer (System.Security.Cryptography.X509Certificates.X509Certificate serverCertificate, AsyncCallback asyncCallback, object asyncState);
abstract member BeginAuthenticateAsServer : System.Security.Cryptography.X509Certificates.X509Certificate * AsyncCallback * obj -> IAsyncResult
override this.BeginAuthenticateAsServer : System.Security.Cryptography.X509Certificates.X509Certificate * AsyncCallback * obj -> IAsyncResult
Public Overridable Function BeginAuthenticateAsServer (serverCertificate As X509Certificate, asyncCallback As AsyncCallback, asyncState As Object) As IAsyncResult

參數

serverCertificate
X509Certificate

X509Certificate 可用來驗證伺服器。

asyncCallback
AsyncCallback

AsyncCallback 委派,會於驗證完成時參考要叫用的方法。

asyncState
Object

使用者定義物件,包含作業的相關資訊。 作業完成時會將這個物件傳遞給 asyncCallback 委派。

傳回

IAsyncResult 物件,指出非同步作業的狀態。

例外狀況

serverCertificatenull

驗證失敗,且此物件處於不穩定的狀態。

已經進行驗證。

-或-

先前已嘗試過使用此 SslStream 進行用戶端驗證。

-或-

驗證已在進行中。

此物件已關閉。

在 Windows 95、Windows 98 或 Windows Millennium 上不支援 BeginAuthenticateAsServer 方法。

備註

從 .NET Framework 4.7 開始,此方法會使用 None 進行驗證,讓作業系統選擇最適用的通訊協定,並封鎖不安全的通訊協定。 在 .NET Framework 4.6 (和已安裝最新安全性修補程式的 .NET Framework 4.5) 中,允許的 TLS/SSL 通訊協定版本為 1.2、1.1 和 1.0 (除非您編輯 Windows 登錄來停用強式加密)。 驗證期間不會檢查憑證撤銷清單。 用戶端不需要提供憑證以進行驗證。

呼叫 方法必須完成 EndAuthenticateAsClient 非同步驗證作業。 一般而言,委派會叫 asyncCallback 用 方法。

此方法不會在作業完成時封鎖。 若要封鎖直到作業完成為止,請使用其中 AuthenticateAsClient 一個方法多載。

如需使用非同步程式設計模型的詳細資訊,請參閱 以非同步方式呼叫同步方法

如果您收到 AuthenticationException ,這 SslStream 已不再可供使用。 您應該關閉這個物件,並移除它的所有參考,以便垃圾收集行程可以收集它。

適用於

BeginAuthenticateAsServer(X509Certificate, Boolean, Boolean, AsyncCallback, Object)

來源:
SslStream.cs
來源:
SslStream.cs
來源:
SslStream.cs

已由伺服器呼叫來開始非同步作業,以使用指定的憑證、需求及系統預設安全性通訊協定來驗證伺服器和用戶端 (選擇性)。

public:
 virtual IAsyncResult ^ BeginAuthenticateAsServer(System::Security::Cryptography::X509Certificates::X509Certificate ^ serverCertificate, bool clientCertificateRequired, bool checkCertificateRevocation, AsyncCallback ^ asyncCallback, System::Object ^ asyncState);
public virtual IAsyncResult BeginAuthenticateAsServer (System.Security.Cryptography.X509Certificates.X509Certificate serverCertificate, bool clientCertificateRequired, bool checkCertificateRevocation, AsyncCallback? asyncCallback, object? asyncState);
public virtual IAsyncResult BeginAuthenticateAsServer (System.Security.Cryptography.X509Certificates.X509Certificate serverCertificate, bool clientCertificateRequired, bool checkCertificateRevocation, AsyncCallback asyncCallback, object asyncState);
abstract member BeginAuthenticateAsServer : System.Security.Cryptography.X509Certificates.X509Certificate * bool * bool * AsyncCallback * obj -> IAsyncResult
override this.BeginAuthenticateAsServer : System.Security.Cryptography.X509Certificates.X509Certificate * bool * bool * AsyncCallback * obj -> IAsyncResult
Public Overridable Function BeginAuthenticateAsServer (serverCertificate As X509Certificate, clientCertificateRequired As Boolean, checkCertificateRevocation As Boolean, asyncCallback As AsyncCallback, asyncState As Object) As IAsyncResult

參數

serverCertificate
X509Certificate

X509Certificate 可用來驗證伺服器。

clientCertificateRequired
Boolean

Boolean 值,指定是否需要求用戶端提供憑證以進行驗證。 請注意,這只是一個要求 -- 如果未提供任何憑證,伺服器仍然會接受連接要求。

checkCertificateRevocation
Boolean

Boolean 值,指定是否要在驗證期間檢查憑證撤銷清單。

asyncCallback
AsyncCallback

AsyncCallback 委派,會於驗證完成時參考要叫用的方法。

asyncState
Object

使用者定義物件,包含作業的相關資訊。 作業完成時會將這個物件傳遞給 asyncCallback 委派。

傳回

IAsyncResult 物件,表示非同步作業的狀態。

例外狀況

serverCertificatenull

驗證失敗,且此物件處於不穩定的狀態。

已經進行驗證。

-或-

先前已嘗試過使用此 SslStream 進行伺服器驗證。

-或-

驗證已在進行中。

此物件已關閉。

在 Windows 95、Windows 98 或 Windows Millennium 上不支援 BeginAuthenticateAsServer 方法。

備註

從 .NET Framework 4.7 開始,此方法會使用 None 進行驗證,讓作業系統選擇最適用的通訊協定,並封鎖不安全的通訊協定。 在 .NET Framework 4.6 (和已安裝最新安全性修補程式的 .NET Framework 4.5) 中,允許的 TLS/SSL 通訊協定版本為 1.2、1.1 和 1.0 (除非您編輯 Windows 登錄來停用強式加密)。

呼叫 方法必須完成 EndAuthenticateAsServer 非同步驗證作業。 一般而言,委派會叫 asyncCallback 用 方法。

此方法不會在作業完成時封鎖。 若要封鎖直到作業完成為止,請使用其中 AuthenticateAsServer 一個方法多載。

如需使用非同步程式設計模型的詳細資訊,請參閱 以非同步方式呼叫同步方法

如果您收到 AuthenticationException ,這 SslStream 已不再可供使用。 您應該關閉這個物件,並移除它的所有參考,以便垃圾收集行程可以收集它。

適用於

BeginAuthenticateAsServer(X509Certificate, Boolean, SslProtocols, Boolean, AsyncCallback, Object)

來源:
SslStream.cs
來源:
SslStream.cs
來源:
SslStream.cs

已由伺服器呼叫來開始非同步作業,以使用指定的憑證、需求及安全性通訊協定來驗證伺服器和用戶端 (選擇性)。

public:
 virtual IAsyncResult ^ BeginAuthenticateAsServer(System::Security::Cryptography::X509Certificates::X509Certificate ^ serverCertificate, bool clientCertificateRequired, System::Security::Authentication::SslProtocols enabledSslProtocols, bool checkCertificateRevocation, AsyncCallback ^ asyncCallback, System::Object ^ asyncState);
public virtual IAsyncResult BeginAuthenticateAsServer (System.Security.Cryptography.X509Certificates.X509Certificate serverCertificate, bool clientCertificateRequired, System.Security.Authentication.SslProtocols enabledSslProtocols, bool checkCertificateRevocation, AsyncCallback? asyncCallback, object? asyncState);
public virtual IAsyncResult BeginAuthenticateAsServer (System.Security.Cryptography.X509Certificates.X509Certificate serverCertificate, bool clientCertificateRequired, System.Security.Authentication.SslProtocols enabledSslProtocols, bool checkCertificateRevocation, AsyncCallback asyncCallback, object asyncState);
abstract member BeginAuthenticateAsServer : System.Security.Cryptography.X509Certificates.X509Certificate * bool * System.Security.Authentication.SslProtocols * bool * AsyncCallback * obj -> IAsyncResult
override this.BeginAuthenticateAsServer : System.Security.Cryptography.X509Certificates.X509Certificate * bool * System.Security.Authentication.SslProtocols * bool * AsyncCallback * obj -> IAsyncResult
Public Overridable Function BeginAuthenticateAsServer (serverCertificate As X509Certificate, clientCertificateRequired As Boolean, enabledSslProtocols As SslProtocols, checkCertificateRevocation As Boolean, asyncCallback As AsyncCallback, asyncState As Object) As IAsyncResult

參數

serverCertificate
X509Certificate

X509Certificate 可用來驗證伺服器。

clientCertificateRequired
Boolean

Boolean 值,指定是否需要求用戶端提供憑證以進行驗證。 請注意,這只是一個要求 -- 如果未提供任何憑證,伺服器仍然會接受連接要求。

enabledSslProtocols
SslProtocols

SslProtocols 值,代表用於驗證的通訊協定。

checkCertificateRevocation
Boolean

Boolean 值,指定是否要在驗證期間檢查憑證撤銷清單。

asyncCallback
AsyncCallback

AsyncCallback 委派,會於驗證完成時參考要叫用的方法。

asyncState
Object

使用者定義物件,包含作業的相關資訊。 作業完成時會將這個物件傳遞給 asyncCallback 委派。

傳回

IAsyncResult 物件,表示非同步作業的狀態。

例外狀況

serverCertificatenull

enabledSslProtocols 不是有效的 SslProtocols 值。

驗證失敗,且此物件處於不穩定的狀態。

已經進行驗證。

-或-

先前已嘗試過使用此 SslStream 進行伺服器驗證。

-或-

驗證已在進行中。

此物件已關閉。

在 Windows 95、Windows 98 或 Windows Millennium 上不支援 BeginAuthenticateAsServer 方法。

備註

從 .NET Framework 4.7 開始,此方法會使用 None 進行驗證,讓作業系統選擇最適用的通訊協定,並封鎖不安全的通訊協定。 在 .NET Framework 4.6 (和已安裝最新安全性修補程式的 .NET Framework 4.5) 中,允許的 TLS/SSL 通訊協定版本為 1.2、1.1 和 1.0 (除非您編輯 Windows 登錄來停用強式加密)。

呼叫 方法必須完成 EndAuthenticateAsServer 非同步驗證作業。 一般而言,委派會叫 asyncCallback 用 方法。

此方法不會在作業完成時封鎖。 若要封鎖直到作業完成為止,請使用其中 AuthenticateAsServer 一個方法多載。

如需使用非同步程式設計模型的詳細資訊,請參閱 以非同步方式呼叫同步方法

如果您收到 AuthenticationException ,這 SslStream 已不再可供使用。 您應該關閉這個物件,並移除它的所有參考,以便垃圾收集行程可以收集它。

適用於