我创建了应该使用证书的 wcf 服务。我使用自签名证书的测试工作完美,但是当我尝试在服务器上运行它时,所有更改都发生了变化,证书由 CA 生成。我使用 CA 生成客户端和服务器证书,然后将服务器证书导出到“受信任的人”文件夹。(我放置在 LocalMachine 目录中的两个证书)。我还授予了证书的所有必要权限。
当我运行出现异常的客户端程序时出现问题:
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>
有人知道我的错误在哪里吗?