Binding validation failed because the wshttpbinding does not support reliable sessions over transport security over HTTPS

280 views Asked by At

I have seriously ran into a problem and could not resolve it. I have searched a ton of forums but couldn't find anything matching to resolve my issue.

I have two components. One is a WCF service and the other is a client which is basically a hardware that fetches the information from the web service. The WCF service is hosted over IIS with https. The client was able to hit the service when the SSL certificate was not installed, but after the installation of SSL certificate the machine started giving the error I mentioned in the title of my question.

This is the web.config of my service `




  <system.serviceModel>
    <!--<behaviors>
      <serviceBehaviors>
        <behavior name="">
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true"
      multipleSiteBindingsEnabled="true" />-->
    <bindings>
      <wsHttpBinding>
        <binding name="wshttpbinding" bypassProxyOnLocal="true" receiveTimeout="00:10:00">
          <reliableSession inactivityTimeout="23:00:00" enabled="true"/>
          <security mode="None">
            <transport clientCredentialType="None" />
            <message clientCredentialType="None" establishSecurityContext="false" />
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>
    <services>
      <service behaviorConfiguration="Services.ServiceBehavior" name="CJDWebServices.Service">
        <endpoint address="" binding="wsHttpBinding" bindingConfiguration="wshttpbinding"
          contract="CJDWebServices.IService">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost/TxService/" />
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="Services.ServiceBehavior">
          <!-- To avoid disclosing metadata information, 
          set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="True"/>
          <!-- To receive exception details in faults for debugging purposes, 
          set the value below to true.  Set to false before deployment 
          to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="False" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
 
</configuration>

`

And this is the app.config of my application running on the hardware `

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <system.serviceModel>
        <bindings>
            <wsHttpBinding>
              <binding name="WSHttpBinding_IService" closeTimeout="00:01:00"
    openTimeout="00:01:00" receiveTimeout="00:25:00" sendTimeout="00:25:00"
    bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
    maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
    messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
    allowCookies="false">
                <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="16384"
                    maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
                <reliableSession ordered="true" inactivityTimeout="23:59:00"
                    enabled="True" />
                <security mode="Transport">
                  <transport clientCredentialType="Windows" proxyCredentialType="None"
                      realm="" />
                  <message clientCredentialType="Windows" negotiateServiceCredential="true"
                      establishSecurityContext="true" />
                </security>
              </binding>
              <binding name="WSHttpBinding_IMachineMgmt" closeTimeout="00:02:00"
                    openTimeout="00:02:00" receiveTimeout="00:25:00" sendTimeout="00:25:00"
                    bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
                    maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
                    messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
                    allowCookies="false">
                <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647"
                    maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
                <reliableSession ordered="true" inactivityTimeout="23:59:00"
                    enabled="true" />
                <security mode="Transport">
                  <transport clientCredentialType="Windows" proxyCredentialType="None"
                      realm="" />
                  <message clientCredentialType="Windows" negotiateServiceCredential="true"
                      establishSecurityContext="true" />
                </security>
              </binding>
              <binding name="WSHttpBinding_IPM" closeTimeout="00:02:00" openTimeout="00:02:00"
                  receiveTimeout="00:05:00" sendTimeout="00:05:00" bypassProxyOnLocal="false"
                  transactionFlow="false" hostNameComparisonMode="StrongWildcard"
                  maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
                  messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
                  allowCookies="false">
                <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647"
                    maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
                <reliableSession ordered="true" inactivityTimeout="00:10:00"
                    enabled="true" />
                <security mode="Transport">
                  <transport clientCredentialType="Windows" proxyCredentialType="None"
                      realm="" />
                  <message clientCredentialType="Windows" negotiateServiceCredential="true"
                      establishSecurityContext="true" />
                </security>
              </binding>
            </wsHttpBinding>
        </bindings>
     
        <client>
            <endpoint address="https://dummy1/dummy1/dummy1.svc" binding="wsHttpBinding"  <!-- This is the one causing trouble --!>
                bindingConfiguration="WSHttpBinding_IService" contract="IService"
                name="WSHttpBinding_IService">
                <identity>
                    <dns value="dummy1" />
                </identity>
            </endpoint>
            <endpoint address="https://dummy2/dummy2/dummy2.asmx" binding="wsHttpBinding"
              bindingConfiguration="WSHttpBinding_IMachineMgmt"
              contract="MonService.IMachineMgmt" name="WSHttpBinding_IMachineMgmt">
            <identity>
              <dns value="dummy2" />
            </identity>
          </endpoint>
          <endpoint address="https://dummy3/dummy3/" binding="wsHttpBinding"
               bindingConfiguration="WSHttpBinding_IPM" contract="IPM" name="WSHttpBinding_IPM">
            <identity>
              <dns value="dummy3" />
            </identity>
          </endpoint>
        </client>
    </system.serviceModel>

  <appSettings>
    <empty here>
  </appSettings>
</configuration>

` The service mentioned below is my pain area

 <endpoint address="https://dummy1/dummy1/dummy1.svc" binding="wsHttpBinding"  <!-- This is the one causing trouble --!>
                bindingConfiguration="WSHttpBinding_IService" contract="IService"
                name="WSHttpBinding_IService">
                <identity>
                    <dns value="dummy1" />
                </identity>
            </endpoint>

I have tried playing around with changing the security mode from none to transport and vice versa, but no luck. I even tried it on the web service configuration file but still no luck.

The service is accessible on the machine by the URL if I browse it on the browser

1

There are 1 answers

0
QI You On

In response to your problem, I propose the following two solutions: 1.First of all, in the MSDN post there is an example of using wshttpbinding transport, accompanied by the corresponding code, you can learn about it. Here is the web.config on its server side:

<system.serviceModel>
    <protocolMapping>
      <add scheme="https" binding="wsHttpBinding" />
    </protocolMapping>
    <bindings>
      <wsHttpBinding>
        <!-- configure wsHttp binding with Transport security mode and clientCredentialType as None -->
        <binding>
          <security mode="Transport">
            <transport clientCredentialType="None"/>
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>
    <!--For debugging purposes set the includeExceptionDetailInFaults attribute to true-->
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To expose metadata over a secure transport uncomment the serviceMetadata behavior
               and the mex endpoint above
               Note: you must have a valid certificate for svcutil to work -->
          <!--<serviceMetadata httpsGetEnabled="True"/>-->
          <serviceDebug includeExceptionDetailInFaults="False" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

Here is the app.config on its client side:

<system.serviceModel>
    <client>
      <!-- this endpoint has an https: address -->
      <endpoint address="https://localhost/servicemodelsamples/service.svc" binding="wsHttpBinding" bindingConfiguration="Binding1" contract="Microsoft.Samples.TransportSecurity.ICalculator"/>
    </client>
    <bindings>
      <wsHttpBinding>
        <!-- configure wsHttpbinding with Transport security mode
                   and clientCredentialType as None -->
        <binding name="Binding1">
          <security mode="Transport">
            <transport clientCredentialType="None"/>
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>
  </system.serviceModel>

2.Finally, you can try to use custom bindings: wcf custom bindings