网上搜索,都说是.net framework版本太低,改为.net 4.5以上版本即可。于是使用vs2017环境测试了下,使用.net framework4.5版本确实可以正常返回结果,低于这个版本就报错。 但我的项目环境版本低,无法升级。后来通过fiddler抓包发现需要TLS协议版本是1.2的,而framework4.5以下版本SecurityProtocolType定义的TLS协议是1.0的,4.5以上是有1.2版本。后来在发送HTTPS请求前加入下行代码解决问题

ServicePointManager.SecurityProtocol = (SecurityProtocolType)192 | (SecurityProtocolType)768 | (SecurityProtocolType)3072;

 

----------转载

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-19
  • 2022-02-07
  • 2021-11-08
猜你喜欢
  • 2022-02-11
  • 2021-11-09
  • 2022-12-23
  • 2021-09-05
  • 2021-12-12
  • 2021-05-25
  • 2022-12-23
相关资源
相似解决方案