我想实现一个 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/