简体   繁体   English

WCF错误 - 安全处理器无法在消息中找到安全标头

[英]WCF Error - Security processor was unable to find a security header in the message

I'm getting what appears now to be a security error in my WCF Service. 我现在看到的是我的WCF服务中出现的安全错误。 Originally my error was about a falted state(removed using around client proxy to clear this error), but have found more information through enabling trace. 最初我的错误是关于一个falted状态(删除使用客户端代理来清除此错误),但通过启用跟踪找到了更多信息。

I have been unable to get my solution running after encountering this error, and even my backup copy now gets the same error. 遇到此错误后,我无法让我的解决方案运行,甚至我的备份副本现在也会出现相同的错误。 I'm not sure what has caused this to happen, I undone the changes I made (nothing relating to WCF) and still get the same error. 我不确定是什么导致了这种情况发生,我撤消了我所做的更改(与WCF无关)并仍然得到相同的错误。

The error from trace is - System.ServiceModel.Security.MessageSecurityException: Security processor was unable to find a security header in the message. 跟踪错误是 - System.ServiceModel.Security.MessageSecurityException:安全处理器无法在消息中找到安全标头。 This might be because the message is an unsecured fault or because there is a binding mismatch between the communicating parties. 这可能是因为消息是不安全的故障,或者因为通信方之间存在绑定不匹配。 This can occur if the service is configured for security and the client is not using security. 如果为安全性配置服务且客户端未使用安全性,则会发生这种情况。

I'm not really sure what I need to do to fix this, any help would be usefull. 我不确定我需要做些什么来解决这个问题,任何帮助都会有用。 The application was previously working. 该应用程序以前工作。

Despite the binding mismatch you can force WCF to work by setting the 尽管绑定不匹配,您可以通过设置强制WCF来工作

Security 安全
enableUnsecuredResponse="true" enableUnsecuredResponse = “真”

Below is more of a code sample that you can use to compare against your own settings... 下面是一个代码示例,您可以使用它来与您自己的设置进行比较...

<security enableUnsecuredResponse="true"
          authenticationMode="MutualCertificateDuplex"
          defaultAlgorithmSuite="TripleDesRsa15"
          includeTimestamp="false"
          messageSecurityVersion="Default" >
  <issuedTokenParameters defaultMessageSecurityVersion="Default">
    <issuer address="" binding="" bindingConfiguration="">
      <identity>
        <certificateReference storeLocation="CurrentUser"
                              x509FindType="FindBySerialNumber"
                              findValue="0b 8d a9 18 59 65 36 b9 de 65 8b 21 ba 6c ab cc"
                              isChainIncluded="true" />
      </identity>
    </issuer>
  </issuedTokenParameters>
</security>

If you want to avoid configuring a custom binding, you can get a reference to the current basicHttpBinding, create a custom binding from it, and include the EnabledUnsecuredResponse property: 如果要避免配置自定义绑定,可以获取对当前basicHttpBinding的引用,从中创建自定义绑定,并包含EnabledUnsecuredResponse属性:

  //client is a reference to your gerenated proxy client class
  var elements = client.Endpoint.Binding.CreateBindingElements();
  elements.Find<SecurityBindingElement>().EnableUnsecuredResponse = true;
  client.Endpoint.Binding = new CustomBinding(elements);

You might find your problem is related to this thread: 您可能会发现您的问题与此主题有关:

WCF service errors after installing WindowsXP updates 安装WindowsXP更新后WCF服务错误

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

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