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

Unhandled Exception: System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a send. ---> System.IO.IOException: Authentication failed because the remote party has closed the transport stream.
at System.Net.Security.SslState.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ForceAuthentication(Boolean receiveFirst, Byte[] buffer, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Net.TlsStream.ProcessAuthentication(LazyAsyncResult result)
at System.Net.TlsStream.Write(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.PooledStream.Write(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.ConnectStream.WriteHeaders(Boolean async)
--- End of inner exception stack trace ---

The underlying connection was closed: An unexpected error occured on a send.
基础连接已关闭,发送时发生错误

从信息上看是ssl认证失败,此错误并不是所有https站点都出现,另外报错的站点,用浏览器或是wget一类的工具访问都正常。挑了一个报异常的网站,查看一下连接信息(用的firefox):

使用了比较新的TLS1.2,开始怀疑操作系统不支持,于是开始翻微软网站,找到一个页面:

https://support.microsoft.com/en-us/help/948963/an-update-is-available-to-add-support-for-the-tls-rsa-with-aes-128-cbc-sha-aes128-sha-and-tls-rsa-with-aes-256-cbc-sha-aes256-sha-aes-cipher-suites-in-windows-server-2003

确认了Server 2003确实不支持,需要打个hotfix,之后再尝试就一切正常了。有遇到相同问题的同学可以参考一下。

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)

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

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

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

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

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

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

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

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

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

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

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

  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. 反射实体类拼接SQL语句

    实体类基类: using System; using System.Collections.Generic; using System.Linq; using System.Reflection; u ...

  2. 查找发布地图的 REST URL并查询相关信息

    1.登录ArcGIS Server Manager 2.登录后,里面是以前自己发布的地图服务 3.点击自己发布的地图,然后按下功能选项,再点击箭头来找到URL 4.点击进去,分别能从红圈中找到相关的信 ...

  3. 【转载】Android 的 Handler 机制实现原理分析

    handler在安卓开发中是必须掌握的技术,但是很多人都是停留在使用阶段.使用起来很简单,就两个步骤,在主线程重写handler的handleMessage( )方法,在工作线程发送消息.但是,有没有 ...

  4. Python目录和文件处理总结

    1.判断目录是否存在.判断文件是否存在.创建目录.重命名目录或文件 import os #获取当前目录路径: E:\Work\Projects\python print(os.getcwd()) #判 ...

  5. CODING 2.0:如何通过设计给品牌创造价值?

    升级背景 伴随着 CODING 理念的全面升级,CODING 正构建起覆盖构想到交付的全覆盖工具链,用户注册即可实践敏捷开发与 DevOps,提升软件交付质量与速度. 一直以来,CODING 作为软件 ...

  6. spring框架开发包官网各版本的下载地址

    链接地址https://spring.io/tools3/sts/legacy,推荐迅雷下载

  7. localStorage在不同页面之间的设置值与取值--加密 localStorage与解密localStorage

    在aa.vue页面 <template> <div> <h1>在aa页面设置值</h1> <button @click="shezhi& ...

  8. 初学JavaScript正则表达式(十一)

    JavaScript的对象属性 整理自慕课网教学 点此进入

  9. 详解Vue生命周期---1

    目录 Vue实例的生命周期全过程(图) 在beforeCreate和created钩子函数间的生命周期 created钩子函数和beforeMount间的生命周期 el选项的有无对生命周期过程的影响 ...

  10. requests的请求机制

    库结构: 工作机制: api.py get.post.put.delete等请求方式都在api文件中,另外,api文件中还有个request方法,使用任何一种请求方式都是调用request方法,只是传 ...