<certificate> 元素

指定要用于为对等客户端的消息进行签名和加密的 X.509 证书。

<system.serviceModel>
  <behaviors>
    <endpointBehaviors>
      <endpointBehaviors> 的 <behavior>
        <clientCredentials>
          <clientCredentials> 的 <peer> 元素
            <certificate> 元素

<certificate findValue="String" 
     
storeLocation="LocalMachine/CurrentUser"
      storeName="AddressBook/AuthRoot/CertificateAuthority/Disallowed/My/Root/TrustedPeople/TrustedPublisher"
      X509FindType="FindByThumbPrint/FindBySubjectName/FindBySubjectDistinguishedName/FindByIssuerName/FindByIssuerDistinguishedName/FindBySerialNumber/FindByTimeValid/FindByTimeNotYetValid/FindByTemplateName/FindByApplicationPolicy/FindByCertificatePolicy/FindByExtension/FindByKeyUsage/FindBySubjectKeyIdentifier"
/>

属性和元素

属性

属性 说明

findValue

一个字符串,包含要在 X.509 证书存储中搜索的值。此属性中包含的类型必须满足指定 x509FindType 的要求。默认值为一个空字符串。

storeLocation

指定客户端可用于验证对等方的证书的 X.509 证书存储的位置。包括以下有效值:

  • LocalMachine:分配给本地计算机的证书存储。
  • CurrentUser:分配给当前用户的证书存储。

默认值为 LocalMachine。

storeName

指定要打开的 X.509 证书存储的名称。包括以下有效值:

  • AddressBook:其他用户的证书存储。
  • AuthRoot:第三方证书颁发机构 (CA) 的证书存储。
  • CertificateAuthority:中间证书颁发机构 (CA) 的证书存储。
  • Disallowed:吊销的证书的证书存储。
  • My:个人证书的证书存储。
  • Root:受信任的根证书颁发机构 (CA) 的证书存储。
  • TrustedPeople:直接受信任的人和资源的证书存储。
  • TrustedPublisher:直接受信任的发行者的证书存储。

默认值为 My。

X509FindType

定义要执行的 X.509 搜索的类型。包括以下有效值:

  • FindByThumbPrint
  • FindBySubjectName
  • FindBySubjectDistinguishedName
  • FindByIssuerName
  • FindByIssuerDistinguishedName
  • FindBySerialNumber
  • FindByTimeValid
  • FindByTimeNotYetValid
  • FindByTemplateName
  • FindByApplicationPolicy
  • FindByCertificatePolicy
  • FindByExtension
  • FindByKeyUsage
  • FindBySubjectKeyIdentifier

findValue 属性中包含的类型必须满足指定 X509FindType 的要求。

默认值为 FindBySubjectDistinguishedName。

子元素

无。

父元素

元素 说明

<clientCredentials> 的 <peer> 元素

指定在向对等客户端进行身份验证时使用的凭据。

备注

此配置元素包含对对等网格中的邻居进行身份验证时使用的 X509Certificate2 实例。

有关对等编程的更多信息,请参见Peer to Peer Networking

示例

下面的代码指定如何查找在对等方案中使用的证书。

<behaviors>
 <endpointBehaviors>
  <behavior name="MyEndpointBehavior">
   <clientCredentials>
    <peer>
     <certificate findValue="www.contoso.com" 
                   storeLocation="LocalMachine"
                   x509FindType="FindByIssuerName" />
    </peer>
   </clientCredentials>
  </behavior>
</endpointBehaviors>

另请参见

参考

PeerCredentialElement
Certificate
X509PeerCertificateElement
Certificate

其他资源

Working with Certificates
Peer to Peer Networking
Peer Channel Message Authentication
Peer Channel Custom Authentication
Best Practices for Securing PeerChannel Applications