简体   繁体   中英

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

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.

The error from trace is - System.ServiceModel.Security.MessageSecurityException: Security processor was unable to find a security header in the message. 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

Security
enableUnsecuredResponse="true"

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:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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