locked
Security Negotiation Failed(SecurityNegotiationException) when use WsHttpBinding with windows authen (Message) to connect to a wcf service in windows 8 RRS feed

  • Question

  • Hi Guys,

    As title said, Security Negotiation Failed(SecurityNegotiationException) when use WsHttpBinding with windows authen (Message) to connect to a wcf service in windows 8. The same code works fine in a windows 7.

    It is an self-hosting with below config, and I try to connect it in a same machine. I tried to add UpNIdentity in client, but still failed.  I used a code to access the WCF service, not via config.

    <system.serviceModel>
        <services>
          <service
              name="HelloworldSrv.Service1"
              behaviorConfiguration="HelloWcfServiceBehavior">
            <host>
              <baseAddresses>
                <add baseAddress="http://localhost:9999/hello"/>
              </baseAddresses>
            </host>
            <!-- this endpoint is exposed at the base address provided by host: http://localhost:9999/hello  -->
            <endpoint address="wcf"
                      binding="wsHttpBinding"
                      bindingConfiguration="Binding1"
                      contract="HelloworldSrv.IService1" />
            <!-- the mex endpoint is exposed at http://localhost/servicemodelsamples/service.svc/mex -->
            <endpoint address="mex"
                      binding="mexHttpBinding"
                      contract="IMetadataExchange" />
          </service>
        </services>
    
        <bindings>
          <wsHttpBinding>
            <!-- 
                Following is the expanded configuration section for a WSHttpBinding.
                Each property is configured with the default value.
                See the ReliableSession, TransactionFlow, TransportSecurity, and MessageSecurity
                samples in the WS directory to learn how to configure these features.
                -->
            <binding name="Binding1"
                      bypassProxyOnLocal="false"
                      transactionFlow="false"
                      hostNameComparisonMode="StrongWildcard"
                      maxBufferPoolSize="524288"
                      maxReceivedMessageSize="65536"
                      messageEncoding="Text"
                      textEncoding="utf-8"
                      useDefaultWebProxy="true"
                      allowCookies="false">
              <reliableSession ordered="true"
                               inactivityTimeout="00:10:00"
                               enabled="false" />
              <security mode="Message">
                <message clientCredentialType="Windows"
                         negotiateServiceCredential="true"
                         algorithmSuite="Default"
                         establishSecurityContext="true" />
              </security>
            </binding>
          </wsHttpBinding>
        </bindings>
    
        <!--For debugging purposes set the includeExceptionDetailInFaults attribute to true-->
        <behaviors>
          <serviceBehaviors>
            <behavior name="HelloWcfServiceBehavior">
              <serviceMetadata httpGetEnabled="True"/>
              <serviceDebug includeExceptionDetailInFaults="False" />
            </behavior>
          </serviceBehaviors>
        </behaviors>
    
      </system.serviceModel>
    

    client code

                EndpointAddress epa = new EndpointAddress(new Uri("http://localhost:9999/hello/wcf"));
    
                WSHttpBinding binding = new WSHttpBinding();
                binding.Security.Message.ClientCredentialType = MessageCredentialType.Windows;
                binding.Security.Message.NegotiateServiceCredential = true;
                binding.Security.Message.AlgorithmSuite = SecurityAlgorithmSuite.Default;
                binding.Security.Message.EstablishSecurityContext = false;
                binding.Security.Mode = SecurityMode.Message;
    
                ChannelFactory<IService1> _cf = new ChannelFactory<HelloworldSrv.IService1>(binding, epa);
                IService1 _service = _cf.CreateChannel();
                Console.WriteLine(_service.GetData(2));
                Console.ReadLine();


    Now that choose the destination, so we should keep on

    Thursday, July 5, 2012 4:01 AM

All replies

  • is any one know this?

    Now that choose the destination, so we should keep on

    Monday, July 9, 2012 8:23 AM