简体   繁体   English

如何在运行时将安全协议更新为TLS 1.2

[英]How can I update Security Protocol to TLS 1.2 at run time

Not able to update the security protocol using the below code called in Application_Start of Global.asax, (Probably because the CAS communication is failing well before reaching this line of code) 无法使用Global.asax的Application_Start中调用的以下代码来更新安全协议,(可能是因为CAS通信在到达此代码行之前就已经失败了)

ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;

I have my .net application developed in 4.0 framework which is expected to use security protocol earlier than TLS 1.2. 我有在4.0框架中开发的.net应用程序,该应用程序预期将使用比TLS 1.2更早的安全协议。 I have got a CAS authentication failing to redirect to my application due to TLS issue. 由于TLS问题,我的CAS身份验证未能重定向到我的应用程序。 To resolve this issue I did made a targeted framework change in web.config as below. 为了解决此问题,我确实在web.config中进行了有针对性的框架更改,如下所示。

<httpRuntime requestValidationMode="2.0" targetFramework="4.6" />

But above solution is leading to different problems. 但是上述解决方案导致了不同的问题。 So right now what I'm trying to figure out is to resolve my CAS issue by using Security Protocol update to 1.2. 因此,现在我想弄清楚的是通过使用安全协议更新到1.2解决我的CAS问题。 Please help me how can I deal with my situation. 请帮助我如何处理我的情况。

If .NET 4.5 or greater is installed on your system the code you have posted: ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072; 如果您的系统上安装了.NET 4.5或更高版本,则您发布的代码为: ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072; should work without changing the .NET framework your application is targeting. 无需更改您的应用程序针对的.NET框架即可正常工作。

If you cannot upgrade the .NET framework on your system you will need to set the SchUseStrongCrypto and SystemDefaultTlsVersions registry keys to 1. 如果无法在系统上升级.NET Framework,则需要将SchUseStrongCrypto和SystemDefaultTlsVersions注册表项设置为1。

From: https://docs.microsoft.com/en-us/dotnet/framework/network-programming/tls 来自: https : //docs.microsoft.com/zh-cn/dotnet/framework/network-programming/tls

For .NET Framework 3.5 - 4.5.2 and not WCF 对于.NET Framework 3.5-4.5.2而非WCF

We recommend you upgrade your app to .NET Framework 4.7 or later versions. 我们建议您将应用程序升级到.NET Framework 4.7或更高版本。 If you cannot upgrade, take the following steps. 如果无法升级,请执行以下步骤。 At some point in the future, your application may fail until you upgrade to .NET Framework 4.7 or later versions. 在将来的某个时候,您的应用程序可能会失败,直到您升级到.NET Framework 4.7或更高版本。

Set the SchUseStrongCrypto and SystemDefaultTlsVersions registry keys to 1. See Configuring security via the Windows Registry. SchUseStrongCryptoSystemDefaultTlsVersions注册表项设置为1。请参阅通过Windows注册表配置安全性。 The .NET Framework version 3.5 supports the SchUseStrongCrypto flag only when an explicit TLS value is passed. 仅当传递显式TLS值时,.NET Framework 3.5版才支持SchUseStrongCrypto标志。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM