简体   繁体   English

绑定验证失败,因为 wshttpbinding 不支持基于 HTTPS 传输安全的可靠会话

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

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.一个是 WCF 服务,另一个是客户端,它基本上是一种从 Web 服务获取信息的硬件。 The WCF service is hosted over IIS with https. WCF 服务通过 IIS 使用 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.当未安装 SSL 证书时,客户端能够访问该服务,但在安装 SSL 证书后,机器开始出现我在问题标题中提到的错误。

This is the web.config of my service `这是我服务的 web.config `




  <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 `这是我在硬件上运行的应用程序的 app.config `

<?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.我什至在 Web 服务配置文件上尝试过,但仍然没有成功。

The service is accessible on the machine by the URL if I browse it on the browser如果我在浏览器上浏览它,该服务可以通过 URL 在机器上访问

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.针对你的问题,我提出以下两种解决方案: 1.首先,在MSDN帖子中有一个使用wshttpbinding transport的例子,并附有相应的代码,你可以了解一下。 Here is the web.config on its server side:这是其服务器端的web.config:

<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:这是其客户端的app.config:

<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 2.最后可以尝试使用custom bindings: wcf custom bindings

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

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