WCF wsHttpBinding的Windows身份验证有多安全?

Aka*_*ava 2 .net windows wcf wcf-binding wcf-security

我创建了WCF,我使用wsHttpBinding和MTOM作为消息传输,认证为"Windows".

现在我的服务不是当前的SECURE,它是普通的HTTP,在自定义端口上运行.

WCF的wsHttpBinding的Windows身份验证是否安全?任何人都可以看到密码或通过网络跟踪猜测?

环境信息:

  1. 在互联网上托管
  2. 没有Active Directory,它的单个服务器
  3. 使用服务器的管理员用户名和密码从我的办公室连接
  4. 在客户端,配置文件中未提及密码,它是在运行时输入的.它正常工作,因为输入错误的凭据也会返回某种安全异常.
  5. 在自定义端口89上运行.NET 4.0,目前我在自定义Windows服务的app.config中设置了以下配置,我在自定义Windows服务中安装了本地服务安装的WCF.我已经为每种方法启用了模拟.

这是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)

谢谢, - 阿卡什

Ste*_*gli 5

关于密码的问题: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