.net 使用allowInsecureTransport=true的WCF服务绑定会导致客户端中的更新服务引用失败
这是我在web.config中的服务配置:.net 使用allowInsecureTransport=true的WCF服务绑定会导致客户端中的更新服务引用失败,.net,wcf,exception-handling,wcf-security,wcf-configuration,.net,Wcf,Exception Handling,Wcf Security,Wcf Configuration,这是我在web.config中的服务配置: <binding name="statefulSessionWithUsernameOverTransport"> <security authenticationMode="SecureConversation" requireSecurityContextCancellation="False" allowInsecureTransport="True"> <secureConversationBo
<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.Channel.TransportSecurityBindingElement
错误:安全策略导出失败。该绑定包含TransportSecurityBindingElement,但没有实现ITransportTokenAssertionProvider的传输安全绑定元素。不支持此类策略导出的策略导出*
我明白它想告诉我什么——基本上,我已经禁用了绑定上的传输安全性,该绑定要求它避免损害通过网络传输的凭据。但是-这就是AllownSecureTransport的全部要点。代理生成器可能根本不知道这个属性吗
更新:
看起来wsdl生成器确实无法处理该属性。我不得不回到消息级安全性和一个用于开发的自签名证书。使用消息安全性的优点是能够坚持使用Cassini进行开发,而不是使用全面的IIS
<wsHttpBinding>
<binding name="wshttpDevelopmentBinding">
<security mode="Message">
<message clientCredentialType="UserName" />
</security>
</binding>
</wsHttpBinding>
关于这一点,我读了几遍(例如或),但我从未尝试过。它看起来像WSDL导出中的一个bug,因为当您手动配置服务和客户端时,它应该可以工作,但元数据导出不起作用。第二个链接提出了一些解决方法,但它是丑陋的
我的建议是开发时将allowInsecureTransport设置为false,并将HTTPS设置为test certificate,并在部署应用程序时切换此配置(可以是安装包的一部分)。我遇到了同样的问题。问题似乎在于http传输,因为它没有实现ITransportTokenAssertionProvider接口,但https实现了。我可以通过两种方式解决这个问题:将我的自定义绑定切换到使用https传输,它实现了接口,并将enableUnsecuredResponse=“true”添加到配置中的安全元素,或者编写一个从HttpTransportBindingElement派生的自定义绑定,但实现了必要的接口。我遇到了类似的问题。我在客户机上安装了.NETFramework 3.5的热修复程序,之后它就开始工作了