【问题标题】:WCF Service Binding using allowInsecureTransport=true causes Update Service Reference in Client to fail使用 allowInsecureTransport=true 的 WCF 服务绑定导致客户端中的更新服务引用失败
【发布时间】:2011-04-14 04:26:17
【问题描述】:

这是我在 web.config 中的服务配置:

<binding name="statefulSessionWithUsernameOverTransport">
  <security authenticationMode="SecureConversation"
    requireSecurityContextCancellation="False" allowInsecureTransport="True">
    <secureConversationBootstrap authenticationMode="UserNameOverTransport"/>
  </security>
  <binaryMessageEncoding />
  <httpTransport />
</binding>

<service name="com.example.FooService"
  behaviorConfiguration="usernamePasswordAuthBehavior">
  <endpoint contract="com.example.FooService.IFooService"
    address="custom" binding="customBinding"
    bindingConfiguration="statefulSessionWithUsernameOverTransport" />
</service>

我设置 allowInsecureTransport=True 因为在生产中服务将在 SSL 终止负载均衡器后面运行。从我的 .Net 4.0 客户端调用服务没有任何问题,但尝试在 VS2010 中更新服务引用总是会导致错误:

System.ServiceModel.Channels.TransportSecurityBindingElement 错误:安全策略导出失败。 Binding 包含一个 TransportSecurityBindingElement,但没有实现 ITransportTokenAssertionProvider 的传输安全绑定元素。不支持此类策略导出的策略导出。*

我明白它试图告诉我什么——这基本上是我在绑定上禁用了传输安全性,该绑定要求它避免损害通过网络传输的凭据。但是 - 这就是 allowInsecureTransport 的全部意义所在。会不会是代理生成器根本不知道这个属性?

更新:

看起来wsdl生成器确实无法处理属性。我不得不回到消息级安全和自签名证书进行开发。使用 Message Security 的优势在于能够坚持使用 Cassini 进行开发,而不是使用成熟的 IIS。

<wsHttpBinding>
    <binding name="wshttpDevelopmentBinding">
      <security mode="Message">
        <message clientCredentialType="UserName" />
      </security>
    </binding>
</wsHttpBinding>

【问题讨论】:

    标签: .net wcf exception-handling wcf-security wcf-configuration


    【解决方案1】:

    我遇到了类似的问题。我在客户端机器上安装了 .NET framework 3.5 的热修复程序,然后它就可以工作了。

    【讨论】:

      【解决方案2】:

      我遇到了同样的问题。问题似乎是 http 传输,因为它没有实现 ITransportTokenAssertionProvider 接口,但 https 实现了。我能够解决这两种方法:将我的自定义绑定切换为使用实现接口的 https 传输,并将 enableUnsecuredResponse="true" 添加到配置中的安全元素,或者编写从 HttpTransportBindingElement 派生的自定义绑定但实现必要的接口。

      【讨论】:

        【解决方案3】:

        我读过几次(例如herehere),但我从未尝试过。它看起来像 WSDL 导出中的一个错误,因为当您手动配置服务和客户端时,它应该可以工作,但元数据导出不起作用。第二个链接提出了一些解决方法,但它是丑陋的。

        我的建议是使用 allowInsecureTransport 设置为 false 并使用测试证书进行 HTTPS 开发,并在部署应用程序时切换此配置(可以是安装包的一部分)。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多