代码之家  ›  专栏  ›  技术社区  ›  Oliver Weichhold

wcf service binding using allowSecureRtransport=true导致客户端中的更新服务引用失败

  •  1
  • Oliver Weichhold  · 技术社区  · 14 年前

    这是我在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>
    

    我将allowSecureTransport设置为true,因为在生产环境中,服务将在SSL终止负载平衡器之后运行。从我的.NET 4.0客户端调用服务没有任何问题,但尝试在VS2010中更新服务引用时始终会导致错误:

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

    我明白它想告诉我什么——基本上,我已经禁用了一个绑定上的传输安全,这要求它避免损害通过线路传输的凭证。但是-这就是 允许安全传输 . 可能是代理生成器根本不知道这个属性吗?

    更新:

    看起来WSDL生成器确实无法处理该属性。我必须回到消息级别的安全性和用于开发的自签名证书。使用消息安全性的优点是能够坚持使用Cassini进行开发,而不是使用全面的IIS。

    <wsHttpBinding>
        <binding name="wshttpDevelopmentBinding">
          <security mode="Message">
            <message clientCredentialType="UserName" />
          </security>
        </binding>
    </wsHttpBinding>
    
    3 回复  |  直到 12 年前
        1
  •  2
  •   Shawn Hubbard    14 年前

    我也遇到了同样的问题。问题似乎是HTTP传输,因为它没有实现ITransportTokenAssertionProvider接口,但HTTPS实现了。我能够绕过这两种方法:将我的自定义绑定切换为使用HTTPS传输(它实现接口),并将enableUncuredResponse=“true”添加到配置中的安全元素,或者编写一个从httpTransportBindingElement派生但实现必要接口的自定义绑定。

        2
  •  1
  •   Ladislav Mrnka    14 年前

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

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

        3
  •  0
  •   Bo Persson tox    12 年前

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

    推荐文章