无法通过在web.config中添加appcontext设置将应用程序设置为使用系统默认的TLS版本

10
根据 TLS协议编程的.NET指南,建议在项目目标为.NET 4.6时通过appcontext开关配置安全性。当在控制台应用程序的app.config中添加appcontext时,此方法有效。但是,在网站项目的web.config中添加appconext开关时不起作用。
这是我添加的配置。
<runtime>
   <AppContextSwitchOverrides value="Switch.System.Net.DontEnableSchUseStrongCrypto=false;Switch.System.Net.DontEnableSystemDefaultTlsVersions=false"/>
</runtime>
1个回答

24

在 Web.config 文件中使用 AppContext 开关:

<appSettings>
    <add key="AppContext.SetSwitch:Switch.System.Net.DontEnableSchUseStrongCrypto" value="false" />
    <add key="AppContext.SetSwitch:Switch.System.Net.DontEnableSystemDefaultTlsVersions" value="false" />
</appSettings>

https://github.com/dotnet/docs/issues/6675


2
虽然这个方法可行,但设置 <httpRuntime targetFramework="4.7.2" /> 也可以起作用。 - Tsahi Asher

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接