共用方式為


X509ClientCertificateAuthentication 類別

定義

指定用於驗證用戶端憑證的驗證內容。

public ref class X509ClientCertificateAuthentication
public class X509ClientCertificateAuthentication
type X509ClientCertificateAuthentication = class
Public Class X509ClientCertificateAuthentication
繼承
X509ClientCertificateAuthentication

範例

下列程式碼將示範如何設定這個屬性。

// Create a service host.
Uri httpUri = new Uri("http://localhost/Calculator");
ServiceHost sh = new ServiceHost(typeof(Calculator), httpUri);

// Get a reference to the authentication object.
X509ClientCertificateAuthentication myAuthProperties =
    sh.Credentials.ClientCertificate.Authentication;

// Configure peer trust.
myAuthProperties.CertificateValidationMode =
    X509CertificateValidationMode.PeerTrust;
// Configure chain trust.
myAuthProperties.CertificateValidationMode =
    X509CertificateValidationMode.ChainTrust;
// Configure custom certificate validation.
myAuthProperties.CertificateValidationMode =
    X509CertificateValidationMode.Custom;

// Specify a custom certificate validator (not shown here) that inherits
// from the X509CertificateValidator class.
// creds.ClientCertificate.Authentication.CustomCertificateValidator =
//    new MyCertificateValidator();
' Create a service host.
Dim httpUri As New Uri("http://localhost/Calculator")
Dim sh As New ServiceHost(GetType(Calculator), httpUri)

' Get a reference to the authentication object.
Dim myAuthProperties As X509ClientCertificateAuthentication = _
sh.Credentials.ClientCertificate.Authentication

' Configure peer trust.
myAuthProperties.CertificateValidationMode = X509CertificateValidationMode.PeerTrust
' Configure chain trust.
myAuthProperties.CertificateValidationMode = X509CertificateValidationMode.ChainTrust
' Configure custom certificate validation.
myAuthProperties.CertificateValidationMode = X509CertificateValidationMode.Custom
' Specify a custom certificate validator (not shown here) that inherits 
' from the X509CertificateValidator class. 
' creds.ClientCertificate.Authentication.CustomCertificateValidator = _
'    new MyCertificateValidator()

這個屬性也可以在組態檔中設定。

<serviceCredentials>  
  <clientCertificate>  
     <authentication certificateValidationMode='ChainTrust' />  
  </clientCertificate>  
</serviceCredentials>  

備註

如果 CertificateValidationMode 設定為 Custom,您就必須建立繼承自 X509CertificateValidator 類別的自訂憑證驗證程式。 如需詳細資訊,請參閱 如何:建立採用自訂憑證驗證程式的服務

屬性

CertificateValidationMode

取得或設定憑證驗證模式。

CustomCertificateValidator

取得或設定自訂用戶端憑證驗證程式。

IncludeWindowsGroups

取得或設定值,這個值會指出 Windows 群組是否包含在授權內容中。

MapClientCertificateToWindowsAccount

取得或設定值,這個值會指出憑證是否對應到 Windows 帳戶。

RevocationMode

取得或設定 ChainTrust 和 PeerOrChainTrust X.509 憑證驗證的憑證撤銷模式。

TrustedStoreLocation

取得或設定要在其內容中驗證用戶端憑證鏈結的受信任存放區位置。

方法

Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
ToString()

傳回代表目前物件的字串。

(繼承來源 Object)

適用於

另請參閱