最近做了一个安装包,安装包会弹出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>

Json Post到 https的坑 - the underlying connection was closed an unexpected error occurred on a send(远程服务器未知错误导致关闭)的更多相关文章

  1. The underlying connection was closed: An unexpected error occurred on a send

    操作系统是Windows Server 2003 x64 SP2,使用Framework 4.0,在使用WebClient访问某些特定的HTTPS站点时,会引发异常: Unhandled Except ...

  2. 微信接口问题(The underlying connection was closed: An unexpected error occurred on a send)

    突然在调用微信接口是报:The underlying connection was closed: An unexpected error occurred on a send错误,跟踪了半天,是因为 ...

  3. The underlying connection was closed: An unexpected error occurred on a rece

    服务器问题,在后台访问外网了,特别是https的网站,容易出这个问题. 修改服务器配置,或修改代码解决.

  4. The underlying connection was closed: An unexpected error occurred on a receive

    解决方法 webRequest.KeepAlive = false; ServicePointManager.ServerCertificateValidationCallback += (s, ce ...

  5. Web Server 使用WebClient 发送https请求 The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel

    使用WebClient 发送https请求 使用WebClient发送请求时,并且是以https协议: WebClient webClient = new WebClient(); string re ...

  6. [bug]The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.

    写在前面 在模拟请求的时候,如果url为https的,会报这个错误.大概错误就是:基础连接已关闭:无法建立信任关系的SSL / TLS的安全通道. The underlying connection ...

  7. EX:The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.

    EX:The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secu ...

  8. [WebException: The underlying connection was closed: The message length limit was exceeded.]解决方法

    [WebException: The underlying connection was closed: The message length limit was exceeded.]   Syste ...

  9. windows xp .net framework 4.0 HttpWebRequest 报The underlying connection was closed,基础连接已关闭

    windows xp .net framework 4.0 HttpWebRequest 报The underlying connection was closed,基础连接已关闭,错误的解决方法 在 ...

随机推荐

  1. L115

    The reasons of reading books - part I1. You will optimize your brain powerThis shouldn't come as a s ...

  2. 尚硅谷Java视频教程导航(学习路线图)

    最近很火,上去看了看,对于入门的人还是有点作用的,做个记号,留着以后学习. Java视频教程下载导航(学习路线图) 网站地址:http://www.atguigu.com/download.shtml

  3. 二:HTML文本编译器 kindeditor-4.1.10 的使用 SpringMVC+jsp的实现

    这和一篇与上一篇的区别在与,上一篇是直接请求到action我们剩下的都是我们全部手动处理, 而这一片篇是由kindeditor内部处理,图片上传到本地,基本上没什么区别,但是有一点一定要注意的就是,这 ...

  4. ASP.NET MVC5中View显示Html

    @Html.Raw(Model.Name) @(new HtmlString(Model.Name));

  5. DATAX动态参数数据传递

    实例:ORACLE到ORACLE的数据传递   编写job.xml文件,添加变量参数 执行datax.py文件时记得带参数 格式:./datax.py –p"-Ddbname=*** -Di ...

  6. Linux应用程序调用其他程序执行

    一.system 1.作用 在Linux应用程序中调用另一个程序: 2.用法 system("/sbin/ifconfig"): 二.popen 1.作用 调用另一个程序执行,同时 ...

  7. 关于移动端的一些tip

    移动端的一些tip 开发相关 关于viewport <meta name="viewport" content="name=value,name=value&quo ...

  8. AngularJS:路由

    ylbtech-AngularJS:路由 1.返回顶部 1. AngularJS 路由 本章节我们将为大家介绍 AngularJS 路由. AngularJS 路由允许我们通过不同的 URL 访问不同 ...

  9. PostgreSQL 数据库角色

    数据库角色PostgreSQL使用角色的概念管理数据库访问权限.一个角色可以被看成是一个数据库用户或者是一个数据库用户组,这取决于角色被怎样设置.角色可以拥有数据库对象(例如,表和函数)并且能够把那些 ...

  10. rails 自定义校验及validates_each多校验

    一.自定义校验 使用 validate 方法传入一个同名方法的 Symbol 即可. validate :my_validation private def my_validation if name ...