我是否需要在ASP .NET 4.6应用程序中强制使用TLS 1.2?

Equ*_*lsk 3 c# asp.net .net-4.6 tls1.2

我们有一个第三方API,很快就会强制使用TLS 1.2.

我们有两个独立的应用程序连接到这个API,一个控制台应用程序和一个ASP.NET Web应用程序,都是用C#编写的.

我已经重新定位控制台应用程序以使用.NET 4.6,它也安装在主机上.我在顶部添加了这个Main.

private static void Main(string[] args)
{
    // Enable TLS 1.2
    ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls12;

   // Disable old protocols
   ServicePointManager.SecurityProtocol &= ~(SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | SecurityProtocolType.Tls11);

    ...

}
Run Code Online (Sandbox Code Playgroud)

我相信这对于控制台应用程序来说已经足够了,因为它只有这一个入口点.

但是我对我需要为ASP.NET Web应用程序做什么感到困惑.

首先它由3个项目组成.两个是框架和服务层的类库,第三个是UI的ASP Web应用程序.我已经浏览了其中的每一个并将它们作为.NET 4.6的目标.
从我读过的内容来看,这听起来就像我需要做的一样,因为默认情况下会协商最高协议.

我对么?

如果我错了,我在哪里从控制台应用添加相同的行?Global.asax中?

Pat*_*man 6

既然ServicePointManager.SecurityProtocol是a static,你只需要为每个应用程序配置一次.这意味着它足以将代码放入Application_Start事件中.