Aka*_*ava 2 .net windows wcf wcf-binding wcf-security
我创建了WCF,我使用wsHttpBinding和MTOM作为消息传输,认证为"Windows".
现在我的服务不是当前的SECURE,它是普通的HTTP,在自定义端口上运行.
WCF的wsHttpBinding的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>
Run Code Online (Sandbox Code Playgroud)
以下是在运行时完成的客户端配置,
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);
Run Code Online (Sandbox Code Playgroud)
谢谢, - 阿卡什
关于密码的问题:Windows身份验证使用Kerberos或NTLM,两种协议都不以明文形式传输密码.
此信息写在此处:http: //msdn.microsoft.com/en-us/library/ff647076.aspx
您应该使用集成Windows身份验证而不是基本身份验证,因为它避免通过网络传输用户凭据.
这意味着您不需要SSL来保护您的密码,但如果您有其他敏感信息(在您的服务呼叫中),那么您应该考虑使用加密(例如SSL).我没试过这个,但它应该让你开始:
http://www.codeproject.com/KB/WCF/WCFSSL.aspx
另一种选择是加密消息(消息安全性而不是传输安全性).这是另一个可以帮助您入门的链接:
http://msdn.microsoft.com/en-us/library/ms733137.aspx
| 归档时间: |
|
| 查看次数: |
9110 次 |
| 最近记录: |