最近做了一个安装包,安装包会弹出dotnet的 窗体,这个安装包会去调用https的一个api。用测试程序测试窗体都是好的。一旦打入安装包后,就报错。研究了半天,原来是https惹的祸

解决方案:
  1. .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 以上版本,默认就可以了

  2. .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 

  1. .NET 4.0. TLS 1.2 is not supported, but if you have .NET 4.5 (or above) installed on the system then you still can opt in for TLS 1.2 even if your application framework doesn’t support it. The only problem is that SecurityProtocolType in .NET 4.0 doesn’t have an entry for TLS1.2, so we’d have to use a numerical representation of this enum value:

    ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;

  1. .NET 3.5 or below. TLS 1.2 is not supported (*) and there is no workaround. Upgrade your application to more recent version of the framework. DOTNET3.5不支持

各种tls版本兼容写法:

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls

其实默认配置DOTNET 4.6.1 以上版本就可以了,但是因为我是安装包,没法写配置文件.....

  <startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>

最新文章

  1. SOUI更新到2.0
  2. jQuery代码节选(事件)
  3. 前端学习笔记——移动前端UI选择
  4. PHP API接口测试小工具
  5. Javascript 布尔操作符总结
  6. github上写blog
  7. 树分治 点分治poj 2114
  8. Python类的特点 (2) :类属性与实例属性的关系
  9. 【C++沉思录】代理类
  10. 高通APQ8074 spi 接口配置
  11. CSS3中box-shadow的用法介绍
  12. jQuery日期和时间插件(jquery-ui-timepicker-addon.js)中文破解版使用
  13. hdu 5607 graph (矩阵乘法快速幂)
  14. jetty启动设置端口
  15. tornado+websocket+mongodb实现在线视屏文字聊天
  16. Java 一个关于使用&amp;&amp;导致的BUG
  17. 【数位dp】Beautiful Numbers @2018acm上海大都会赛J
  18. js插件---bootstrap-datepicker.js是什么
  19. Codechef September Challenge 2018 游记
  20. mysql定时执行某任务

热门文章

  1. 【转】Python获取当前系统时间
  2. 什么是 PCB 的压适孔
  3. 常用Kerberos指令
  4. BZOJ2096:[POI2010]Pilots
  5. DIY ESXI虚拟化服务器再度升级ESXI6.0 (U盘安装Esxi)
  6. 怎么设置myeclipse的格式化键格式每行的字符长度
  7. d-s证据理论
  8. flask 电影系统(2)
  9. js正则基础总结和工作中常用验证规则
  10. 自定义Android Studio方法注释模板