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

标签 .net windows wcf wcf-binding wcf-security

我创建了 WCF,并使用 wsHttpBinding 和 MTOM 作为消息传输,并将身份验证作为“Windows”。

现在我的服务不是当前安全的,它是纯 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>

以下是在运行时完成的客户端配置,

        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);

谢谢, - 阿卡什

最佳答案

关于您关于密码的问题:Windows 身份验证使用 Kerberos 或 NTLM,并且这两种协议(protocol)都不以明文形式传输密码。

此信息写在这里: http://msdn.microsoft.com/en-us/library/ff647076.aspx

You should use Integrated Windows authentication instead of basic authentication because it avoids transmitting user credentials over the network.

这意味着您不需要 SSL 来保护您的密码,但如果您有其他敏感信息(在您的服务调用中),那么您应该考虑使用加密(例如 SSL)。我没有尝试过这个,但它应该可以帮助您入门:

http://www.codeproject.com/KB/WCF/WCFSSL.aspx

另一种选择是加密消息(消息安全而不是传输安全)。这是另一个可以帮助您入门的链接:

http://msdn.microsoft.com/en-us/library/ms733137.aspx

关于.net - WCF wsHttpBinding 的 Windows 身份验证有多安全?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2906685/

相关文章:

pythonnet 无法从 vb .net dll 调用方法 - TypeError

c++ - 获取应用程序目录中的文件列表

windows - 学习低级 WinAPI 编程是否仍然有意义?

c++ - Qt 应用程序和 Windows 资源管理器之间的剪切和粘贴剪贴板交换

c# - 如何在 .NET 的基类静态方法中获取类类型?

.net - 使用 dotnet core 登录 FluentD?

wcf - 将相关 token 传递给 WCF 服务?

wcf - WCF 场景中的自签名证书性能

c# - WCF 中的 WSDL URI 是什么?

c++ - D8048 : cannot compile C file 'openssl\applink.c' with/ZW option