SslStream.AuthenticateAsClient 方法

定義

驗證主從架構連接的用戶端。

多載

AuthenticateAsClient(SslClientAuthenticationOptions)

已由用戶端呼叫來在用戶端與伺服器連線中驗證伺服器和用戶端 (選擇性)。

AuthenticateAsClient(String)

已由用戶端呼叫來在用戶端與伺服器連線中驗證伺服器和用戶端 (選擇性)。

AuthenticateAsClient(String, X509CertificateCollection, Boolean)

已由用戶端呼叫來在用戶端與伺服器連線中驗證伺服器和用戶端 (選擇性)。 驗證程序會使用指定的憑證集合物件和系統預設的 SSL 通訊協定。

AuthenticateAsClient(String, X509CertificateCollection, SslProtocols, Boolean)

已由用戶端呼叫來在用戶端與伺服器連線中驗證伺服器和用戶端 (選擇性)。 驗證處理序使用指定的憑證集合和 SSL 通訊協定。

AuthenticateAsClient(SslClientAuthenticationOptions)

已由用戶端呼叫來在用戶端與伺服器連線中驗證伺服器和用戶端 (選擇性)。

public:
 void AuthenticateAsClient(System::Net::Security::SslClientAuthenticationOptions ^ sslClientAuthenticationOptions);
public void AuthenticateAsClient (System.Net.Security.SslClientAuthenticationOptions sslClientAuthenticationOptions);
member this.AuthenticateAsClient : System.Net.Security.SslClientAuthenticationOptions -> unit
Public Sub AuthenticateAsClient (sslClientAuthenticationOptions As SslClientAuthenticationOptions)

參數

sslClientAuthenticationOptions
SslClientAuthenticationOptions

SSL 連線的屬性包。

例外狀況

targetHostnull

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

已經進行驗證。

-或-

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

-或-

驗證已在進行中。

此物件已關閉。

備註

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

驗證成功時,您必須檢查 IsEncryptedIsSigned 屬性,以判斷 所使用的 SslStream 安全性服務。 IsMutuallyAuthenticated檢查 屬性,以判斷是否發生相互驗證。

如果驗證失敗,您會收到 AuthenticationException ,因此 SslStream 無法再使用。 您應該關閉這個物件,並移除它的所有參考,以便垃圾收集行程可以收集它。

適用於

AuthenticateAsClient(String)

已由用戶端呼叫來在用戶端與伺服器連線中驗證伺服器和用戶端 (選擇性)。

public:
 virtual void AuthenticateAsClient(System::String ^ targetHost);
public virtual void AuthenticateAsClient (string targetHost);
abstract member AuthenticateAsClient : string -> unit
override this.AuthenticateAsClient : string -> unit
Public Overridable Sub AuthenticateAsClient (targetHost As String)

參數

targetHost
String

伺服器的名稱,共用這個 SslStream

例外狀況

targetHostnull

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

已經進行驗證。

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

-或- 驗證已在進行中。

此物件已關閉。

備註

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

驗證成功時,您必須檢查 IsEncryptedIsSigned 屬性,以判斷 所使用的 SslStream 安全性服務。 IsMutuallyAuthenticated檢查 屬性,以判斷是否發生相互驗證。

如果驗證失敗,您會收到 AuthenticationException ,因此 SslStream 無法再使用。 您應該關閉這個物件,並移除它的所有參考,以便垃圾收集行程可以收集它。

適用於

AuthenticateAsClient(String, X509CertificateCollection, Boolean)

已由用戶端呼叫來在用戶端與伺服器連線中驗證伺服器和用戶端 (選擇性)。 驗證程序會使用指定的憑證集合物件和系統預設的 SSL 通訊協定。

public:
 virtual void AuthenticateAsClient(System::String ^ targetHost, System::Security::Cryptography::X509Certificates::X509CertificateCollection ^ clientCertificates, bool checkCertificateRevocation);
public virtual void AuthenticateAsClient (string targetHost, System.Security.Cryptography.X509Certificates.X509CertificateCollection? clientCertificates, bool checkCertificateRevocation);
public virtual void AuthenticateAsClient (string targetHost, System.Security.Cryptography.X509Certificates.X509CertificateCollection clientCertificates, bool checkCertificateRevocation);
abstract member AuthenticateAsClient : string * System.Security.Cryptography.X509Certificates.X509CertificateCollection * bool -> unit
override this.AuthenticateAsClient : string * System.Security.Cryptography.X509Certificates.X509CertificateCollection * bool -> unit
Public Overridable Sub AuthenticateAsClient (targetHost As String, clientCertificates As X509CertificateCollection, checkCertificateRevocation As Boolean)

參數

targetHost
String

伺服器的名稱,將共用這個 SslStream

clientCertificates
X509CertificateCollection

X509CertificateCollection,包含用戶端憑證。

checkCertificateRevocation
Boolean

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

備註

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

驗證成功時,您必須檢查 IsEncryptedIsSigned 屬性,以判斷 所使用的 SslStream 安全性服務。 IsMutuallyAuthenticated檢查 屬性,以判斷是否發生相互驗證。

如果驗證失敗,您會收到 AuthenticationException ,因此 SslStream 無法再使用。 您應該關閉這個物件,並移除它的所有參考,以便垃圾收集行程可以收集它。

注意

SSL 第 2 版通訊協定不支援用戶端憑證。

適用於

AuthenticateAsClient(String, X509CertificateCollection, SslProtocols, Boolean)

已由用戶端呼叫來在用戶端與伺服器連線中驗證伺服器和用戶端 (選擇性)。 驗證處理序使用指定的憑證集合和 SSL 通訊協定。

public:
 virtual void AuthenticateAsClient(System::String ^ targetHost, System::Security::Cryptography::X509Certificates::X509CertificateCollection ^ clientCertificates, System::Security::Authentication::SslProtocols enabledSslProtocols, bool checkCertificateRevocation);
public virtual void AuthenticateAsClient (string targetHost, System.Security.Cryptography.X509Certificates.X509CertificateCollection? clientCertificates, System.Security.Authentication.SslProtocols enabledSslProtocols, bool checkCertificateRevocation);
public virtual void AuthenticateAsClient (string targetHost, System.Security.Cryptography.X509Certificates.X509CertificateCollection clientCertificates, System.Security.Authentication.SslProtocols enabledSslProtocols, bool checkCertificateRevocation);
abstract member AuthenticateAsClient : string * System.Security.Cryptography.X509Certificates.X509CertificateCollection * System.Security.Authentication.SslProtocols * bool -> unit
override this.AuthenticateAsClient : string * System.Security.Cryptography.X509Certificates.X509CertificateCollection * System.Security.Authentication.SslProtocols * bool -> unit
Public Overridable Sub AuthenticateAsClient (targetHost As String, clientCertificates As X509CertificateCollection, enabledSslProtocols As SslProtocols, checkCertificateRevocation As Boolean)

參數

targetHost
String

伺服器的名稱,將共用這個 SslStream

clientCertificates
X509CertificateCollection

X509CertificateCollection,包含用戶端憑證。

enabledSslProtocols
SslProtocols

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

checkCertificateRevocation
Boolean

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

備註

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

驗證成功時,您必須檢查 IsEncryptedIsSigned 屬性,以判斷 所使用的 SslStream 安全性服務。 IsMutuallyAuthenticated檢查 屬性,以判斷是否發生相互驗證。

如果驗證失敗,您會收到 AuthenticationException ,因此 SslStream 無法再使用。 您應該關閉這個物件,並移除它的所有參考,以便垃圾收集行程可以收集它。

注意

SSL 第 2 版通訊協定不支援用戶端憑證。

適用於