繁体   English   中英

具有证书消息安全性的WCF wsHttpBinding

[英]WCF wsHttpBinding with certificate message security

我正在尝试使用带有证书的消息安全性来创建客户端和服务应用程序。 但是我一直都有一些错误,无法正常工作。 有人可以建议我的配置文件出了什么问题吗?

这是服务配置:

  <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"/>

这是测试客户端配置

  <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>

我目前的例外是:

System.ServiceModel.ServiceActivationException:无法激活请求的服务'http://wcftest.pvt/SecuredCommunication/Service1.svc'。 请参阅服务器的诊断跟踪日志以获取更多信息。

对我来说配置看起来不错,我使用MSDN上的一些手册创建了它,所以我不明白哪里出了问题。 我使用像这样的makecert.exe工具安装了证书

makecert.exe MakeCert -pe -ss我的-sr LocalMachine -a sha1 -sky exchange -n CN = wcftest.pvt

谢谢,亚历山大。

在服务配置中,替换

<serviceMetadata httpGetBinding="true"/> 

通过

<serviceMetadata httpsGetBinding="true"/> 

这与绑定中应用的安全通道配置匹配。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM