WCF服务TLS 1.2实施

时间:2019-12-12 07:03:35

标签: wcf tls1.2 wcf-security


我们正在尝试在WCF服务中实施TLS 1.2。
我们将WCF服务托管在VM Box上的IIS上。 我们不确定如何为我们的服务禁用TLS 1.0和TLS 1.1。 我们尝试了以下方法:

我们的WCF服务(服务器端)和(客户端)**中的配置更改–

对于客户端,我们在main方法中添加了以下代码–


Remove insecure protocols (SSL3, TLS 1.0, TLS 1.1) 
ServicePointManager.SecurityProtocol &= ~SecurityProtocolType.Ssl3; 
ServicePointManager.SecurityProtocol &= ~SecurityProtocolType.Tls; 
ServicePointManager.SecurityProtocol &= ~SecurityProtocolType.Tls11;  
// Add TLS 1.2, 1.3
ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls12;
ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls13;

我们已经验证了它可以在客户端使用,即,在此配置之后,客户端仅使用TLS 1.2发送请求。      但是,服务器端WCF服务上的相同配置不起作用。      我们已经在Application_Start方法的global.asax文件中写入了此配置更改      服务器,但IIS服务器上托管的WCF服务仍接受TLS 1.0 / 1.1请求。

我们尝试了另一种方法,其中我们在Windows Server上进行了注册表项更改,以对整个VM框禁用TLS 1.0,TLS 1.1。 使用此方法的障碍是,我们的VM上还有许多其他服务, 如果我们在整个服务器上进行配置更改,则可能会受到影响。

是否有任何可行的方法可以更改WCF服务的配置以在服务级别上禁用TLS 1.0 / 1.1请求的服务?
任何帮助将不胜感激。 :-)

1 个答案:

答案 0 :(得分:0)

首先,我们最好不要手动指定TLS版本,只是让OS决定TLS版本。请检查TLS最佳做法的正式文档。
https://docs.microsoft.com/en-us/dotnet/framework/network-programming/tls
假设操作系统和项目的SDK支持TLS1.2(需要先决条件,Dotnet4.6.1 +,win7 +),我们可以通过下面的客户端代码指定在通信过程中使用的TLS版本。

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
            ServiceReference1.ServiceClient client = new ServiceReference1.ServiceClient();

此外,修改Windows注册表可以禁用某些版本协议。 请参考以下链接。
https://serverfault.com/questions/733994/how-to-disable-tls-1-0-in-windows-2012-rdp
https://docs.microsoft.com/en-us/windows-server/security/tls/tls-registry-settings
请随时告诉我是否有什么我可以帮助的。

相关问题