<clientCertificate> 項目的 <authentication>
為服務使用的用戶端憑證指定驗證行為。
<<system.serviceModel>>
<behaviors>
<serviceBehaviors>
<serviceBehaviors> 的 <behavior>
<serviceCredentials>
<serviceCredentials> 的 <clientCertificate>
<clientCertificate> 項目的 <authentication>
<authentication
customCertificateValidatorType="namespace.typeName, [,AssemblyName] [,Version=version number] [,Culture=culture] [,PublicKeyToken=token]"
certificateValidationMode="ChainTrust/None/PeerTrust/PeerOrChainTrust/Custom"
includeWindowsGroups="Boolean"
mapClientCertificateToWindowsAccount="Boolean"
revocationMode="NoCheck/Online/Offline"
trustedStoreLocation="CurrentUser/LocalMachine"
/>
屬性和項目
屬性
屬性 | 描述 |
---|---|
customCertificateValidatorType |
選擇性字串。用來驗證自訂型別的型別和組件。當 certificateValidationMode 設定為 Custom 時,必須設定這個屬性。 |
certificateValidationMode |
選擇性列舉。指定用來驗證認證之三個模式的其中一個。如果設定為 Custom,也必須提供 customCertificateValidator。預設為 ChainTrust。 |
includeWindowsGroups |
選擇性布林值。指定 Windows 群組是否包含在安全性內容中。將這個屬性設定為 true 會有效能方面的影響,因為它會造成完整的群組擴充。如果您不需要建立使用者所屬之群組的清單,請將此屬性設定為 false。 |
mapClientCertificateToWindowsAcccount |
布林值,指定是否能夠使用憑證將用戶端對應至 Windows 身分識別。必須啟用 Active Directory 才能這麼做。如需使用 Active Directory 功能的詳細資訊,請參閱 http://technet2.microsoft.com/WindowsServer/en/Library/0602148e-1a8f-4917-bb01-6fd342aba7161033.mspx (本頁面可能為英文)。 |
revocationMode |
選擇性列舉。用於檢查撤銷憑證清單 (RCL) 的模式之一。預設為 Online。 |
trustedStoreLocation |
選擇性列舉。兩個系統存放位置的其中一個:LocalMachine 或 CurrentUser。當與用戶端交涉服務憑證時,會使用這個值。會針對指定之存放位置內的 [受信任的人] 存放區來執行驗證。預設為 CurrentUser。 |
子項目
無。
父項目
項目 | 描述 |
---|---|
定義對服務驗證用戶端時使用的 X.509 憑證。 |
備註
<authentication> 項目對應至 X509ClientCertificateAuthentication 類別。它可讓您自訂驗證用戶端的方法。您可以將 certificateValidationMode 屬性 (Attribute) 設定為 None、ChainTrust、PeerOrChainTrust、PeerTrust 或 Custom。根據預設,層級會設為 ChainTrust,指定每一個憑證必須出現在鏈結頂端以「根授權」(Root Authority) 為結尾的憑證階層中。這是最安全的模式。您也可以將值設定為 PeerOrChainTrust,指定可接受自行發出的憑證 (對等信任),以及信任鏈結內的憑證。這個值會在開發及偵錯用戶端和服務時使用,因為自行發出的憑證不需要從受信任的授權單位購買。部署用戶端時,請改用 ChainTrust 值。
您也可以將值設定為 Custom。設定為 Custom 值時,您還必須將 customCertificateValidatorType 屬性設定為可用來驗證憑證的組件與型別。若要建立自己的自訂驗證程式,您必須繼承自抽象 X509CertificateValidator 類別。如需詳細資訊,請參閱 How To: Create a Service Employing a Custom Certificate Validator。
範例
下列程式碼會在 <authentication> 項目中指定 X.509 憑證和自訂驗證類型。
<serviceBehaviors>
<behavior name="myServiceBehavior">
<clientCertificate>
<certificate
findValue="www.cohowinery.com"
storeLocation="CurrentUser"
storeName="TrustedPeople"
x509FindType="FindByIssuerName" />
<authentication customCertificateValidatorType="MyTypes.Coho"
certificateValidationMode="Custom"
revocationMode="Offline"
includeWindowsGroups="false"
mapClientCertificateToWindowsAccount="true" />
</clientCertificate>
</behavior>
</serviceBehaviors>
請參閱
參考
X509ClientCertificateAuthentication
X509CertificateValidationMode
Authentication
Authentication
X509ClientCertificateAuthenticationElement
其他資源
Security Behaviors in WCF
How To: Create a Service Employing a Custom Certificate Validator
Working with Certificates