WCF服务配置异常";证书可能没有私钥……”;
在我前面的问题-,之后,我需要配置一个WCF服务,该服务将使用WS-Security接收SOAP请求(可以在链接中找到请求示例) 这是我的配置文件:WCF服务配置异常";证书可能没有私钥……”;,wcf,soap,ws-security,Wcf,Soap,Ws Security,在我前面的问题-,之后,我需要配置一个WCF服务,该服务将使用WS-Security接收SOAP请求(可以在链接中找到请求示例) 这是我的配置文件: <system.serviceModel> <services> <service name="Service.Service1" behaviorConfiguration="customBindingBehavior"> <endpoint address="ht
<system.serviceModel>
<services>
<service name="Service.Service1" behaviorConfiguration="customBindingBehavior">
<endpoint address="http://localhost/Service1.svc"
binding="customBinding"
bindingConfiguration="NewBinding0"
name="ServiceEndpoint"
contract="Service.Contracts.IService1" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="customBindingBehavior">
<serviceDebug includeExceptionDetailInFaults="true"/>
<serviceMetadata httpGetEnabled="true" />
<serviceCredentials>
<serviceCertificate findValue="xxx" x509FindType="FindByThumbprint" storeLocation="LocalMachine" storeName="My" />
<clientCertificate>
<certificate findValue="yyy" x509FindType="FindByThumbprint" storeLocation="LocalMachine" storeName="TrustedPeople" />
</clientCertificate>
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<customBinding>
<binding name="NewBinding0">
<textMessageEncoding messageVersion="Soap11WSAddressingAugust2004" />
<security authenticationMode="MutualCertificate">
<secureConversationBootstrap />
</security>
<httpTransport />
</binding>
</customBinding>
</bindings>
</system.serviceModel>
</configuration>
从消息中不清楚错误是否在服务器或客户端证书上。无论如何,您只需要配置服务器证书。将根据您可以在行为中指定的策略验证客户端证书 您可以使用此绑定:
<customBinding>
<binding name="NewBinding0">
<textMessageEncoding messageVersion="Soap11" />
<security authenticationMode="MutualCertificate" messageSecurityVersion="WSSecurity10WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10">
<secureConversationBootstrap />
</security>
<httpTransport />
</binding>
</customBinding>
在Windows 8.1上使用Visual Studio 2012调试客户端应用程序时,我遇到了相同的问题。根据给出的错误消息,从Visual Studio运行应用程序时也会出现此错误。打开Visual Studio“以管理员身份运行”可解决此问题。请检查您是否拥有pricate密钥以及对其拥有权限。更多信息请尝试暂时使用不同的密钥,可能是wcf示例中提供的且已知有效的密钥。要查看我的答案中是否存在相同的错误,请参阅其中的config+属性定义立即尝试另一个证书。可能您的进程没有权限。我已使用make cert.exe在-sky之后创建了一个具有“exchange”值的证书(而不是我以前使用的“signature”值),现在一切都很好!这是什么原因?
<customBinding>
<binding name="NewBinding0">
<textMessageEncoding messageVersion="Soap11" />
<security authenticationMode="MutualCertificate" messageSecurityVersion="WSSecurity10WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10">
<secureConversationBootstrap />
</security>
<httpTransport />
</binding>
</customBinding>
[ServiceContract(ProtectionLevel=System.Net.ProtectionLevel.Sign)]