0

我创建了应使用证书的wcf服务。我使用自签名证书的测试非常完美,但是当我尝试在服务器上运行证书时,所有更改都由CA生成。我使用CA生成了客户端和服务器证书,然后将服务器证书导出到“受信任的人”文件夹。 (我放置到LocalMachine目录的两个证书)。此外,我已授予所有必要的证书权限。WCF服务证书不在可信人员存储中

的X.509证书CN = xxxx是不是在信任的人店:

的问题时,我正在那里我得到异常的客户端程序出现。

这里是我的服务器配置

<services> 
    <service behaviorConfiguration="MyServiceBehavior" name="PoswsService"> 
    <endpoint address="http://xxxx/PoswsService.svc" binding="wsHttpBinding" bindingConfiguration="MyServiceBinding" 
     contract="IPoswsService" /> 
    <endpoint address="http://xxxx/mex" binding="mexHttpBinding" name="MetadataBinding" 
     contract="IMetadataExchange" /> 
    </service> 
    </services> 
    <behaviors> 
     <serviceBehaviors> 
      <behavior name="MyServiceBehavior"> 
       <serviceCredentials> 
       <clientCertificate> 
        <authentication certificateValidationMode="PeerOrChainTrust" revocationMode="Online"/> 
       </clientCertificate> 
       <serviceCertificate findValue="xxxxxxxxxxxxxxxxxxxxx" storeLocation="LocalMachine" 
        storeName="My" x509FindType="FindBySerialNumber" /> 
       </serviceCredentials> 
       <serviceMetadata httpGetEnabled="true" /> 
       <serviceDebug includeExceptionDetailInFaults="true" /> 
      </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <bindings> 
     <wsHttpBinding> 
     <binding name="MyServiceBinding"> 
      <security> 
       <message clientCredentialType="Certificate"/> 
      </security> 
     </binding> 
     </wsHttpBinding> 
    </bindings> 
    </system.serviceModel> 

下面是客户端配置

<system.serviceModel> 
    <bindings> 
     <wsHttpBinding> 
      <binding name="WSHttpBinding_IPoswsService" 
       bypassProxyOnLocal="false" transactionFlow="false" > 
       <security mode="Message"> 
        <transport clientCredentialType="Windows" proxyCredentialType="None" 
         realm="" /> 
        <message clientCredentialType="Certificate" negotiateServiceCredential="true" 
         algorithmSuite="Default" /> 
       </security> 
      </binding> 
     </wsHttpBinding> 
    </bindings> 
    <client> 
     <endpoint address="http://xxxx/PoswsService.svc" 
      binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IPoswsService" 
      contract="TestService.IPoswsService" name="WSHttpBinding_IPoswsService" behaviorConfiguration="CustomBehavior"> 
      <identity> 
       <certificate encodedValue="long word" /> 
      </identity> 
     </endpoint> 
    </client> 

    <behaviors> 
    <endpointBehaviors> 
     <behavior name="CustomBehavior"> 
     <clientCredentials> 
      <clientCertificate findValue="xxxxxxxxxxxxxxxxxxx" x509FindType="FindBySerialNumber" storeLocation="CurrentUser" storeName="My"/> 
      <serviceCertificate> 
      <authentication certificateValidationMode="PeerTrust"/> 
      </serviceCertificate> 
     </clientCredentials> 
     </behavior> 
    </endpointBehaviors> 
    </behaviors> 
</system.serviceModel> 

是否有人知道在哪里可以做我的错误呢?

回答

-1

我没有太多的WCF经验,但通常情况下,您希望将CA证书放置在可信位置。客户应该有自己的可信赖的位置,并且CA证书也需要去那里。如果这是一个生产服务,您需要将客户端和服务器的certificateValidationMode更改为“ChainTrust”,这意味着它将信任链接到CA证书的证书。 “PeerTrust”意味着您只需将您想要信任的实际证书放入信任位置即可。这page可能有助于看。