【发布时间】:2010-05-25 16:54:02
【问题描述】:
我创建了 WCF,并使用 wsHttpBinding 和 MTOM 作为消息传输,身份验证为“Windows”。
现在我的服务不是当前的 SECURE,它是纯 HTTP,在自定义端口上运行。
WCF 的 wsHttpBinding 的 Windows 身份验证是否安全?任何人都可以通过网络跟踪看到密码或猜测吗?
环境信息:
- 在 Internet 上托管
- 没有 Active Directory,只有一个服务器
- 使用服务器的管理员用户名和密码从我的办公室连接
- 在客户端,配置文件中没有提到密码,它是在运行时输入的。它可以正常工作,因为输入错误的凭据也会返回某种安全异常。
- 在自定义端口 89 上运行 .NET 4.0,目前我在自定义 Windows 服务的 app.config 中设置了以下配置,我将 WCF 托管在作为本地服务安装的自定义 Windows 服务中。我已在每种方法上启用了模拟。
这里是 app.config
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="metaAndErrors">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
<serviceAuthorization impersonateCallerForAllOperations="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="CustomServiceHost.CustomService"
behaviorConfiguration="metaAndErrors"
>
<endpoint address="" binding="wsHttpBinding"
bindingConfiguration="wsHttpLargeBinding"
contract="CustomServiceHost.ICustomService"/>
<endpoint address="mex" binding="mexHttpBinding"
contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:89/CustomService" />
</baseAddresses>
</host>
</service>
</services>
<bindings>
<wsHttpBinding>
<binding
name="wsHttpLargeBinding" messageEncoding="Mtom"
maxReceivedMessageSize="2147483647">
<readerQuotas maxArrayLength="512000"/>
</binding>
</wsHttpBinding>
</bindings>
</system.serviceModel>
以下是在运行时完成的客户端配置,
WSHttpBinding binding = new WSHttpBinding();
binding.Security.Message.ClientCredentialType
= MessageCredentialType.Windows;
binding.Security.Mode = SecurityMode.Message;
binding.MessageEncoding = WSMessageEncoding.Mtom;
binding.ReaderQuotas.MaxArrayLength = 512000;
CustomServiceClient cc = new CustomServiceClient(
binding,
new EndpointAddress(string.Format(
"http://{0}:89/CustomService",
host.ServerHost))
);
cc.ClientCredentials.Windows.AllowedImpersonationLevel
= System.Security.Principal.TokenImpersonationLevel.Impersonation;
cc.ClientCredentials.Windows.ClientCredential
= new NetworkCredential(host.Username, host.Password);
谢谢你, - 阿卡什
【问题讨论】:
-
wsHttpBinding 有默认加密的消息。你在说什么密码?
-
您能否在问题中添加有关您的环境的更多信息?您的应用程序是在 Intranet 还是 Internet 环境中运行?您的网络中是否有 Active Directory 等?您使用哪个版本的 .NET?
-
有完整源代码示例的最终解决方案吗?
标签: .net windows wcf wcf-binding wcf-security