最近作了一个安装包,安装包会弹出dotnet的 窗体,这个安装包会去调用https的一个api。用测试程序测试窗体都是好的。一旦打入安装包后,就报错。研究了半天,原来是https惹的祸api
:解决方案
.NET 4.6 and above. You don’t need to do any additional work to support TLS 1.2, it’s supported by default.DOTNET 4.6.1 以上版本,默认就能够了app
.NET 4.5. TLS 1.2 is supported, but it’s not a default protocol. You need to opt-in to use it. The following code will make TLS 1.2 default, make sure to execute it before making a connection to secured resource:测试
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12
this
ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;
spa
各类tls版本兼容写法:code
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tlsit
其实默认配置DOTNET 4.6.1 以上版本就能够了,可是由于我是安装包,无法写配置文件.....io
<startup> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" /> </startup>