.Net Framework 4.6.1 not defaulting to TLS 1.2

后端 未结 11 2173
暖寄归人
暖寄归人 2020-11-30 23:45

Our client have recently upgrade the security protocol to TLS 1.2. Therefore We have our application upgraded to 4.6.1 expecting the security protocol will be default to TLS

11条回答
  •  心在旅途
    2020-12-01 00:00

    I tried the following code in my api which is not working for Kaltura account integration(bec'z Kaltura API upgraded to TLS 1.2) and it start working. .Net framework is 4.5.2 and server :windows server 2008 r2 where application hosted.

    #region To handle TLS (Transport Layer Security) Version and support
                var assembly = Assembly.GetExecutingAssembly();
                var attributes = assembly.GetCustomAttributes(typeof(TargetFrameworkAttribute), false);
                var version = (TargetFrameworkAttribute)attributes[0];
    
                SecurityProtocolType flag;
                if (Enum.TryParse("Tls11", out flag))
                    ServicePointManager.SecurityProtocol |= flag;
                if (Enum.TryParse("Tls12", out flag))
                    ServicePointManager.SecurityProtocol |= flag;
    #endregion
    

    Thanks.

提交回复
热议问题