WCF自定义绑定相互证书不断收到“必须保护请求消息”错误

时间:2018-08-13 11:44:56

标签: c# wcf web-config x509certificate

我有一台具有wcf soap服务的服务器。通过简单的httpbinding配置,一切都可以完美运行。 在将web.config更改为custombinding之后,我仍然遇到相同的错误:

请求消息必须受到保护。这是合同操作('IMyServices','http://tempuri.org/')所必需的。必须通过绑定(“ BasicHttpBinding”,“ http://tempuri.org/”)提供保护。

这是我的web.config:

<system.serviceModel>
    <bindings>
      <customBinding>
        <binding name="MyBinding">
          <textMessageEncoding messageVersion="Soap11WSAddressingAugust2004" />
          <security authenticationMode="MutualCertificate" requireDerivedKeys="false"
            messageProtectionOrder="SignBeforeEncrypt" messageSecurityVersion="WSSecurity10WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10" />
          <httpTransport keepAliveEnabled="false" />
        </binding>
      </customBinding>
    </bindings>
    <services>
      <service behaviorConfiguration="MyBehavior" name="NewWCF.MyServices">
        <endpoint address="" binding="customBinding" bindingConfiguration="MyBinding"
          name="wsHttpMembershipEndpoint" contract="NewWCF.IMyServices" />
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="http://10.130.111.111/NewWCF" />
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="MyBehavior">
          <serviceCredentials>
            <clientCertificate>
              <certificate findValue="CN=Central-Gateway" x509FindType="FindBySubjectDistinguishedName" storeName="TrustedPeople" />
              <authentication revocationMode="NoCheck" 
        certificateValidationMode = "None"/>
            </clientCertificate>
            <serviceCertificate findValue="CN=MySrvTst" x509FindType="FindBySubjectDistinguishedName" storeName="My" storeLocation="LocalMachine" />
          </serviceCredentials>
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
          <serviceSecurityAudit serviceAuthorizationAuditLevel="SuccessOrFailure"
            messageAuthenticationAuditLevel="SuccessOrFailure" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />

lang-xml->

两个证书都正确显示在mmc.exe中

我尝试通过调用.svc路径的浏览器对其进行测试,应该以这种方式工作还是由于证书而失败?

有没有办法看到更详细的错误?

可能是什么问题?

预先感谢, 布莱恩。

0 个答案:

没有答案