[英]WCF wsHttpBinding with certificate message security
I am trying to create client and service applications with Message security with Certificate. 我正在尝试使用带有证书的消息安全性来创建客户端和服务应用程序。 But I have some errors all the time and can't make it work.
但是我一直都有一些错误,无法正常工作。 Could somebody suggest what is wrong with my configuration files?
有人可以建议我的配置文件出了什么问题吗?
This is the service configuration: 这是服务配置:
<system.serviceModel>
<services>
<service name="SecuredCommunication.Service1" behaviorConfiguration="securedBehavior">
<endpoint address="test" binding="wsHttpBinding" bindingName="test" name="fasds" bindingConfiguration="securedWsBinding" contract="SecuredCommunication.IService1" >
</endpoint>
</service>
</services>
<bindings>
<wsHttpBinding>
<binding name="securedWsBinding">
<security mode="Message">
<message clientCredentialType="Certificate"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="securedBehavior">
<serviceMetadata httpGetBinding="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
<serviceCredentials>
<serviceCertificate findValue="wcftest.pvt" storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectName"/>
<clientCertificate>
<authentication certificateValidationMode="PeerTrust"/>
</clientCertificate>
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
and this is the test client configuration 这是测试客户端配置
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior>
<clientCredentials>
<clientCertificate findValue="wcftest.pvt" storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectName"/>
</clientCredentials>
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<wsHttpBinding>
<binding>
<security mode="Message">
<message clientCredentialType="Certificate"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://wcftest.pvt/SecuredCommunication/Service1.svc" binding="wsHttpBinding" contract="SecuredCommunication.IService1">
</endpoint>
</client>
the current exception I have is: 我目前的例外是:
System.ServiceModel.ServiceActivationException: The requested service, 'http://wcftest.pvt/SecuredCommunication/Service1.svc' could not be activated.
System.ServiceModel.ServiceActivationException:无法激活请求的服务'http://wcftest.pvt/SecuredCommunication/Service1.svc'。 See the server's diagnostic trace logs for more information.
请参阅服务器的诊断跟踪日志以获取更多信息。
For me configuration looks ok, I created it using some manuals from MSDN, so I can't understand what is wrong. 对我来说配置看起来不错,我使用MSDN上的一些手册创建了它,所以我不明白哪里出了问题。 I installed certificate using makecert.exe tool like this
我使用像这样的makecert.exe工具安装了证书
makecert.exe MakeCert -pe -ss My -sr LocalMachine -a sha1 -sky exchange -n CN=wcftest.pvt
makecert.exe MakeCert -pe -ss我的-sr LocalMachine -a sha1 -sky exchange -n CN = wcftest.pvt
Thanks, Alexander. 谢谢,亚历山大。
In the service configuration, replace 在服务配置中,替换
<serviceMetadata httpGetBinding="true"/>
by 通过
<serviceMetadata httpsGetBinding="true"/>
This matches the secure channel configuration applied in the bindings. 这与绑定中应用的安全通道配置匹配。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.