KB4344167安全更新中断了TLS代码

希望有人可以帮助解决这个问题。 最近我们的机器更新了KB4344167 ,其中包括.NET 4.7.1的安全更新 不幸的是,此更新破坏了我们的Webrequest代码。 当我们运行下面的代码时,我们收到此错误:

请求已中止:无法创建SSL / TLS安全通道。

 // Create a request for the URL. WebRequest request = WebRequest.Create(url); //specify to use TLS 1.2 as default connection ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls; request.Timeout = int.Parse(configmanager.GetSetting("Webtimeout")); // Set proxy request.Proxy = WebRequest.DefaultWebProxy; request.Proxy.Credentials = CredentialCache.DefaultCredentials; // Define a cache policy for this request only. HttpRequestCachePolicy noCachePolicy = new HttpRequestCachePolicy(HttpRequestCacheLevel.NoCacheNoStore); request.CachePolicy = noCachePolicy; ServicePointManager.ServerCertificateValidationCallback = (s, cert, chain, ssl) => true; // Get the response. HttpWebResponse response = (HttpWebResponse)request.GetResponse(); 

从机器上卸载安全更新时,代码执行正常。 我们在上面的代码中遗漏了什么吗? 这就是我唯一能想到的。

任何帮助是极大的赞赏!

@Damien_The_Unbeliever有正确答案。 最终问题是ServicePointManager和Webrequest.Create的顺序。 反转这些行,因此在Webrequest.Create修复问题之前定义了ServicePointManager。 当我们的服务器转移到TLS 1.2时,我仍然不知道为什么在Create修复我们的原始问题后添加ServicePointManager,但我们现在不用担心。

我碰到了类似的东西。 看来MS可能在试图仅启用TLS 1.2时破坏了某些东西。 https://support.microsoft.com/en-us/help/4458166/applications-that-rely-on-tls-1-2-strong-encryption-experience-connect

到目前为止,我已经尝试将建议的配置添加到app.config,它就像一个魅力。 不再有SSL / TLS错误。

注意:我们在有选择地修补的服务器上发现了这一点,即它们还没有MS修复。 我们的开发机器从未见过这个问题。