c# - 带有 Windows 身份验证和 SSL 的 WCF

标签 c# wcf ssl kerberos

我想实现一个 WCF 服务,它使用由 TLS/SSL 保护的 TCP 传输层,并且仍然在服务器上使用 Windows 身份验证(kerberos/NTLM)来识别调用客户端。 Windows 身份验证部分已经可以使用,但我不确定连接是否已加密。

我正在使用 NetTcpBinding 并像这样创建它:

        var binding = new NetTcpBinding()
        {
            ReceiveTimeout = TimeSpan.FromMinutes(30),

            OpenTimeout = TimeSpan.FromMinutes(1),
            CloseTimeout = TimeSpan.FromSeconds(30),

            MaxReceivedMessageSize = int.MaxValue,

            ReliableSession =
            {
                Enabled = true,
                InactivityTimeout = TimeSpan.FromMinutes(1)
            },

            Security =
            {
                Mode = SecurityMode.Transport,
                Transport =
                {
                    ClientCredentialType = TcpClientCredentialType.Windows,
                    ProtectionLevel = ProtectionLevel.EncryptAndSign,
                    SslProtocols = SslProtocols.Tls12
                }
            }
        };

我已经使用 wireshark 嗅探了一些包,并在第一个包中发现了以下内容:“application/negotiate”。

我只是想 110% 确定连接是用 TLS 加密的,但我不是,因为我不知道如何检查它。 在我的环境中无法使用客户端证书。

请不要只粘贴指向某个 Microsoft 网站的链接以了解如何进行设置。 没有示例说明如何同时使用 Windows 身份验证和 TLS。 该应用程序是独立,因此没有 IIS 或其他东西!

感谢任何帮助!

最佳答案

这是具有传输安全性和独立托管的 Net.Tcp 绑定(bind)示例:https://learn.microsoft.com/en-us/dotnet/framework/wcf/feature-details/transport-security-with-windows-authentication

它的配置与您几乎完全一样。唯一的异常(exception)是您添加了可靠的 session (这根本不会影响安全性)并将可用的 SSL 协议(protocol)限制为仅 Tls12(默认值为 Ssl3 | Tls | Tls11 | Tls12).所以,它仍然是安全的。

所以,答案是:是的,它是安全的。

关于c# - 带有 Windows 身份验证和 SSL 的 WCF,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44806197/

相关文章:

c# - 将现有接口(interface)重新用作 WCF 接口(interface)。契约(Contract)装饰是否影响现有应用程序?有什么坏处吗?

Android 在没有弃用方法的情况下向服务器发送 https post 请求

c# - 什么是适合 .NET 的基于 f/oss GDI+(System.Drawing)的图形和图表组件?

C# 将泛型委托(delegate)传递给构造函数

c# - 将自定义 header 添加到 .Net 中的所有 Swagger 响应

c# - 使用 EF CodeFirst 和 DRY 原则进行重复验证

asp.net-mvc - 将 HttpContext.Current.User.Identity 传递给 WCF

c# - 关于 Java 客户端调用 WCF

ssl - 在 Drupal 站点上使用 SSL - 域不安全

java - eclipse 中的 SSL keystore 路径