<serviceCertificate> 的 <authentication> 元素

指定客户端代理用于对使用 SSL/TLS 协商获取的服务证书进行身份验证的设置。

架构层次结构

<system.serviceModel>
  <behaviors>
    <endpointBehaviors>
      <endpointBehaviors> 的 <behavior>
        <clientCredentials>
          <serviceCredentials> 的 <serviceCertificate>
            <serviceCertificate> 的 <authentication> 元素

语法

<authentication customCertificateValidatorType="String" certificateValidationMode="None/PeerTrust/ChainTrust/PeerOrChainTrust/Custom"
revocationMode="NoCheck/Online/Offline" 
trustedStoreLocation="LocalMachine/CurrentUser" />

属性和元素

以下几节描述了属性、子元素和父元素。

属性

属性 说明

customCertificateValidatorType

字符串。一个用于验证自定义类型的类型和程序集。

certificateValidationMode

指定用来验证凭据的三种模式之一。如果设置为 Custom,则还必须提供 customCertificateValidator。默认值为 ChainTrust

revocationMode

用于检查吊销证书列表 (CRL) 的一种模式。默认值为 Online

trustedStoreLocation

两个系统存储位置之一:LocalMachineCurrentUser。在向客户端协商服务证书时使用此值。将根据指定存储位置中的“受信任人”存储执行验证。默认值为 CurrentUser

子元素

无。

父元素

元素 说明

<clientCredentials> 的 <serviceCertificate> 元素

指定客户端对服务进行身份验证时使用的证书。

备注

此配置元素的 certificateValidationMode 属性指定用于对证书进行身份验证的信任级别。默认情况下,该级别设置为 ChainTrust,它指定每个证书都必须存在于某个证书层次结构中,而该层次结构以位于证书链顶端的受信任的证书颁发机构结束。这是最安全的模式。您还可以将此值设置为 PeerOrChainTrust,该值指定受信任的链中的证书以及自行颁发的证书(对等信任)都被接受。因为不需要从受信任的证书颁发机构那里购买自行颁发的证书,所以可以在开发和调试客户端和服务时使用此值。在部署客户端时,请改用 ChainTrust 值。您也可以将该值设置为 CustomNone。若要使用 Custom 值,还必须将 customCertificateValidator 属性设置为程序集和用于验证证书的类型。若要创建您自己的自定义验证程序,必须从 X509CertificateValidator 抽象类进行继承。有关更多信息,请参见How To: Create a Service Employing a Custom Certificate Validator

revocationMode 属性指定检查证书是否已吊销的方式。默认值为 online,指示将自动检查证书是否已吊销。有关更多信息,请参见Working with Certificates

示例

以下示例执行两项任务。它首先指定一个服务证书,以便供客户端在通过 HTTP 协议与域名为 www.contoso.com 的终结点通信时使用。然后,它指定了在身份验证过程中使用的吊销模式和存储位置。

<serviceCertificate>
  <defaultCertificate findValue="www.contoso.com" 
                      storeLocation="LocalMachine"
                      storeName="TrustedPeople" 
                      x509FindType="FindByIssuerDistinguishedName" />
  <scopedCertificates>
     <add targetUri="https://www.contoso.com" 
          findValue="www.contoso.com" storeLocation="LocalMachine"
                  storeName="Root" x509FindType="FindByIssuerName" />
  </scopedCertificates>
  <authentication revocationMode="Online" 
   trustedStoreLocation="LocalMachine" />
</serviceCertificate>

另请参见

参考

<clientCertificate> 的 <authentication> 元素
X509RecipientCertificateClientElement
X509CertificateRecipientClientCredential
Authentication
X509ServiceCertificateAuthentication

其他资源

Security Behaviors in WCF
Working with Certificates
How To: Create a Service Employing a Custom Certificate Validator
Securing Clients
Securing Services and Clients