我正在尝试使用 wsHttpBinding 托管 WCF 服务。我使用 makecert 创建了一个证书,并在 web.config 中放置了一些行。
这是我得到的错误:
System.ArgumentException: The certificate 'CN=WCfServer' must have a private key that is capable of key exchange. The process must have access rights for the private key.
在谷歌搜索时,证书文件的访问权限似乎存在一些问题。我使用 cacls 授予 NETWORK SERVICE 和我的用户名的读取权限,但它没有改变任何内容。
我还进入了证书文件属性中的安全设置,并完全控制了 NETWORK SERVICE 和我的用户名。再次无济于事。
您能指导我解决问题所在以及我需要做什么吗?我对这些证书的东西真的很不满意。
这是我的 web.config:
<system.serviceModel>
<services>
<service name="Abc.Service" behaviorConfiguration="Abc.ServiceBehavior">
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="Abc.BindConfig" contract="Abc.IService">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="Abc.ServiceBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
<serviceCredentials>
<clientCertificate>
<authentication certificateValidationMode="PeerTrust"/>
</clientCertificate>
<serviceCertificate findValue="WCfServer" storeLocation="CurrentUser" storeName="My" x509FindType="FindBySubjectName" />
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<wsHttpBinding>
<binding name="Abc.BindConfig">
<security mode="Message">
<message clientCredentialType="Certificate" />
</security>
</binding>
</wsHttpBinding>
</bindings>
</system.serviceModel>