Web Service Endpoint identity error

2.2k views Asked by At

I have a problem with our web service. We didn't make the web service so we don't know what's really happening. At first, it works in our server but sometimes it doesn't which causes us to restart it. Then now, it shows error message:

Secure channel cannot be opened because security negotiation with the remote endpoint has failed. This may be due to absent or incorrectly specified EndpointIdentity in the EndpointAddress used to create the channel. Please verify the EndpointIdentity specified or implied by the EndpointAddress correctly identifies the remote endpoint.

But our web service is not even secured! Our web config is:

<configuration>
  <connectionStrings>
    <add name="DefaultConnection" connectionString="Server=;Database=;User ID=;Password=;Trusted_Connection=False;" providerName="System.Data.SqlClient" />
  </connectionStrings>
  <system.web>
    <compilation debug="true" targetFramework="4.0" />
    <httpRuntime executionTimeout="3600000" maxRequestLength="102400" />
  </system.web>
  <appSettings>
    <add key="baseAddress" value="http://localhost:20088" />
    <add key="timeout" value="120"/>
    <add key="provider" value="System.Data.SqlClient" />
  </appSettings>
  <system.serviceModel>
    <services>
      <service name="H2WcfService.DataAccess" behaviorConfiguration="H2WcfServiceBehavior">
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:20088"/>
          </baseAddresses>
        </host>
        <endpoint address="" binding="wsHttpBinding" contract="H2WcfService.IDataAccess" bindingConfiguration="DataAccess">
          <identity>
            <dns value="localhost:20088"/>
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
      </service>
      <service name="H2WcfService.LoginService" behaviorConfiguration="H2WcfServiceBehavior">
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:20088"/>
          </baseAddresses>
        </host>
        <endpoint address="" binding="wsHttpBinding" contract="H2WcfService.ILoginService" bindingConfiguration="Authentic">
          <identity>
            <dns value="localhost:20088"/>
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
      </service>
      <service name="H2WcfService.LMSService" behaviorConfiguration="H2WcfServiceBehavior">
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:20088"/>
          </baseAddresses>
        </host>
        <endpoint address="" binding="wsHttpBinding" contract="H2WcfService.ILMSService" bindingConfiguration="LMSService">
          <identity>
            <dns value="localhost:20088"/>
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="H2WcfServiceBehavior" >
          <serviceMetadata httpGetEnabled="false" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
        <behavior name="">
          <serviceMetadata httpGetEnabled="false" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
    <bindings>
      <wsHttpBinding>
        <binding name="DataAccess" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
          <security mode="None">
            <transport clientCredentialType="None" />
            <message establishSecurityContext="false" />
          </security>
        </binding>
        <binding name="Authentic">
          <security mode="None">
            <transport clientCredentialType="None" />
            <message establishSecurityContext="false" />
         </security>
      </binding>
      <binding name="LMSService">
        <security mode="None">
          <transport clientCredentialType="None" />
          <message establishSecurityContext="false" />
        </security>
      </binding>
    </wsHttpBinding>
  </bindings>
</system.serviceModel>
<system.webServer>
  <modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
3

There are 3 answers

1
ezekiel On BEST ANSWER

Finally found the answer! Basically, under Binding in System.Servicemodel of my asp.net application web.config, I should have added:

<security mode="None"/>

It was deleted because I was playing with the code for the web service authentication. Thank God I have multiple backups! Thanks guys! I'll update this as answered after two days.

1
SanyTiger On

Under Security tag, try this

<security mode="None">  

<transport clientCredentialType="Windows" proxyCredentialType="None" realm="" />  

<message clientCredentialType="Windows" negotiateServiceCredential="true" establishSecurityContext="true" />  

</security>
0
Mehmet Kurt On

We have fixed

Old Code

<security mode="TransportWithMessageCredential">
    <transport clientCredentialType="None" />
    <message establishSecurityContext="false" />
</security>
   

New Code

<security mode="TransportWithMessageCredential">
    <transport clientCredentialType="None" proxyCredentialType="None" realm="" />
    <message clientCredentialType="UserName" negotiateServiceCredential="true" algorithmSuite="Default" establishSecurityContext="false" />
</security>