积极答复者
关于wsDualHttpBinding 安全性配置的问题

问题
-
最近写了个使用wsDualHttpBinding 的例子,结果发现 在服务端<security mode="None"/>的情况下 ,客户端<security mode="None"/>只有在本机的情况下才能用,拿到其他电脑上出现 soap安全协商失败。系统都是XP,我的服务是寄宿在IIS5.1的环境中。
现在我有两个问题:
1.我想请教一下如果wsDualBinding想应用于Internet环境中,使用什么样的安全性配置最合适。
2.就是wsDualHttpBinding 到底支持禁用安全性吗,我指的是起码跨机器通讯没问题的,我现在的环境好像就 httpbingding和tcpbinding在禁用安全性的情况下可以通讯。
我接触到的例子都是localhost环境下的,建议各位写例子的时候多考虑下实际的环境。
最后抱怨一下,微软的安全配置实在太晕人了。这里先谢谢各位了。附上我的配置
服务端的
<system.serviceModel>
<services>
<service name="WcfService1.Service1" behaviorConfiguration="WcfService1.Service1Behavior">
<!-- Service Endpoints -->
<endpoint address="" binding="wsDualHttpBinding" contract="WcfService1.IService1">
<!--
部署时,应删除或替换下列标识元素,以反映
在其下运行部署服务的标识。删除之后,WCF 将
自动推导相应标识。
-->
<identity>
<dns value="192.168.1.177"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/></service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="WcfService1.Service1Behavior">
<!-- 为避免泄漏元数据信息,请在部署前将以下值设置为 false 并删除上面的元数据终结点-->
<serviceMetadata httpGetEnabled="true" />
<!-- 要接收故障异常详细信息以进行调试,请将以下值设置为 true。在部署前设置为 false 以避免泄漏异常信息-->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<wsDualHttpBinding>
<binding name ="wsDualHttpBinding">
<security mode="None"/>
</binding>
</wsDualHttpBinding>
</bindings>
</system.serviceModel>
客户端的
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<wsDualHttpBinding>
<binding name="WSDualHttpBinding_IService1" >
<security mode="None"/>
</binding>
</wsDualHttpBinding>
</bindings>
<client>
<endpoint address="http://192.168.1.177/WCFService/Service1.svc" binding="wsDualHttpBinding"
bindingConfiguration="WSDualHttpBinding_IService1" contract="ServiceReference1.IService1"
name="WSDualHttpBinding_IService1">
<identity>
<dns value="192.168.1.177" />
</identity>
</endpoint>
</client>
</system.serviceModel>
</configuration>
答案
-
Hi,
你服务端的终结点没有设置<endpoint address="" binding="wsDualHttpBinding" contract="WcfService1.IService1">
bindingConfiguration。
你虽然使用<binding name ="wsDualHttpBinding">
<security mode="None"/>
</binding>
但是没有应用到这个binding上。
但就你的Internet环境中WCF服务安全来说 使用WCF分布式安全开发实践(10):消息安全模式之自定义用户名密码:Message_UserNamePassword_WSHttpBinding是最好的。
但是大部分公司不愿意支付商业证书的费用,因为消息安全模式要使用证书。
也有不使用证书的情况。
但是安全性就差些。
可以使用明文传递用户名密码。
Frank Xu Lei--谦卑若愚,好学若饥
专注于.NET平台下分布式应用系统开发和企业应用系统集成
Focus on Distributed Applications Development and EAI based on .NET
欢迎访问老徐的中文技术博客:Welcome to My Chinese Technical Blog
欢迎访问微软WCF中文技术论坛:Welcome to Microsoft Chinese WCF Forum
欢迎访问微软WCF英文技术论坛:Welcome to Microsoft English WCF Forum- 已标记为答案 xmuczq 2010年2月3日 1:00
全部回复
-
Hi,
你服务端的终结点没有设置<endpoint address="" binding="wsDualHttpBinding" contract="WcfService1.IService1">
bindingConfiguration。
你虽然使用<binding name ="wsDualHttpBinding">
<security mode="None"/>
</binding>
但是没有应用到这个binding上。
但就你的Internet环境中WCF服务安全来说 使用WCF分布式安全开发实践(10):消息安全模式之自定义用户名密码:Message_UserNamePassword_WSHttpBinding是最好的。
但是大部分公司不愿意支付商业证书的费用,因为消息安全模式要使用证书。
也有不使用证书的情况。
但是安全性就差些。
可以使用明文传递用户名密码。
Frank Xu Lei--谦卑若愚,好学若饥
专注于.NET平台下分布式应用系统开发和企业应用系统集成
Focus on Distributed Applications Development and EAI based on .NET
欢迎访问老徐的中文技术博客:Welcome to My Chinese Technical Blog
欢迎访问微软WCF中文技术论坛:Welcome to Microsoft Chinese WCF Forum
欢迎访问微软WCF英文技术论坛:Welcome to Microsoft English WCF Forum- 已标记为答案 xmuczq 2010年2月3日 1:00
-
谢谢你的回复,禁用安全性的问题搞定了,我发现自己的问题还是蛮多的,居然在代码里面发现了该死的一句
binding.Security.Mode = WSDualHttpSecurityMode.Message;崩溃。。。。。
接着新问题出现了就是ClientBaseAddress,比如客户端是在只有一个对外独立IP的局域网环境中的话,相信很多人都是这么干的吧,拉个3M电信然后大家一起用,那么客户端告诉服务端的ClientBaseAddress就是局域网的地址,那不是很悲剧,如果服务端不知道怎么联系这样的客户端的话,所以我想知道有没有解决的方案。
还有就是wsDualHttpBinding好像只支持消息安全模式,我看了《WCF3.5揭秘》第七章使用用户名和密码的消息安全的例子,发现他的客户端配置里面endpoint是这样配置的<endpoint
address="http://FabrikamEnterprises:8000/Derivatives/AnotherCalculator"
binding="wsHttpBinding" bindingConfiguration="SecureMessageUserName" behaviorConfiguration="UserName"
contract="DerivativesCalculator.IDerivativesCalculator"
name="DerivativesCalculatorServiceUserName"/>
这个地址为什么要写成这样呢,我的意思是在INTERNET中比如Silverlight客户端要使用的时候,服务的地址要怎么样暴露出来呢?再次感谢了。
据说Silverlight只支持pollingDuplex,难道不支持wsDualHttpBinding吗? 这是我今天下午看到的。⊙﹏⊙b汗 -
wsDualHttpBinding确实只支持消息安全。
WSDualHttpBinding 提供与 WSHttpBinding 相同的 Web 服务协定支持,但是如果用于双工协定,WSDualHttpBinding 仅支持 SOAP 安全,且需要可靠的消息传递。此绑定要求客户端具有可为服务提供回调终结点的公共 URI。这由 ClientBaseAddress 提供。双向绑定向服务公开客户端的 IP 地址。客户端应使用安全来确保仅连接到自己信任的服务。
另外你的服务配置 不全吧。
全部的配置是什么。
silverlight 好像不支持wsDualHttpBinding。
Frank Xu Lei--谦卑若愚,好学若饥
专注于.NET平台下分布式应用系统开发和企业应用系统集成
Focus on Distributed Applications Development and EAI based on .NET
欢迎访问老徐的中文技术博客:Welcome to My Chinese Technical Blog
欢迎访问微软WCF中文技术论坛:Welcome to Microsoft Chinese WCF Forum
欢迎访问微软WCF英文技术论坛:Welcome to Microsoft English WCF Forum -
我的 ClientBaseAddress 是在代码中动态设定的,因为端口须要动态的。看来只能去研究pollingDuplex,能介绍下吗,这个技术据说与comet技术有点接近?不知道性能怎么样?
-
google一下
这里有个文章 你看看
http://mtaulty.com/CommunityServer/blogs/mike_taultys_blog/archive/2009/08/19/silverlight-amp-wcf-pollingduplex-channel.aspx
Frank Xu Lei--谦卑若愚,好学若饥
专注于.NET平台下分布式应用系统开发和企业应用系统集成
Focus on Distributed Applications Development and EAI based on .NET
欢迎访问老徐的中文技术博客:Welcome to My Chinese Technical Blog
欢迎访问微软WCF中文技术论坛:Welcome to Microsoft Chinese WCF Forum
欢迎访问微软WCF英文技术论坛:Welcome to Microsoft English WCF Forum