系统从.net framework 升级到dotnet core2.1

原先工作正常的httpclient,会报SSL connection could not be established error 错误

在.net framework中通过ServicePointManager,当证书出错时,可以跳过证书验证。

ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true

升级到dotnet core 2.1后,发现以上配置无效。

  原因是ServicePointManager只对HttpWebRequest有效,.net framework中httpclient是基于HttpWebRequest实现的,所以Httpclient不会报错

在dotnetcore2.1中,Httpclient想要实现相同的功能,需要在HttpClient中设置。

 var handler = new HttpClientHandler
{
ServerCertificateCustomValidationCallback = delegate { return true; }
};

github上有人提过这个问题,可以参见 https://github.com/dotnet/corefx/issues/29452

HttpClient SSL connection could not be established error的更多相关文章

  1. NetCore HttpClient The SSL connection could not be established, see inner exception

    之前遇到一个问题 https://www.cnblogs.com/leoxjy/p/10201046.html 在centos 7.x  HttpClient访问会出问题  The SSL conne ...

  2. The request with exception: The SSL connection could not be established, see inner exception. requestId 解决方案

    DOTNET CORE 部署 Centos7 抛出异常 环境变量如下: .NET Core SDK (reflecting any global.json): Version: 2.2.401 Com ...

  3. powercli The SSL connection could not be established, see inner exception. 问题解决

    Connect-VIServer -Server 这里是"SSL连接不能建立......"这实际上意味着你没有一个有效的证书.如果你想连接到vCenter没有一个有效的证书,您必须 ...

  4. mysql连接error,Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection .....

    完整error Establishing SSL connection without server's identity verification is not recommended. Accor ...

  5. WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default i

    jdbc连接数据库候,对数据进行访问,访问正常当出现如下警告: WARN: Establishing SSL connection without server's identity verifica ...

  6. Java连接Mysql数据库警告: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established

    详细错误: Establishing SSL connection without server's identity verification is not recommended. Accordi ...

  7. How an SSL connection is established

    An SSL connection between a client and server is set up by a handshake, the goals of which are: To s ...

  8. java链接Mysql出现警告:Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by

    Java使用mysql-jdbc连接MySQL出现如下警告: Establishing SSL connection without server's identity verification is ...

  9. 解决Establishing SSL connection without server‘s identity verification is not recommended.

    每次从数据库中进行查询或者其他操作控制台都会出现以下警告,虽说不是error,但是很显眼.. WARN: Establishing SSL connection without server's id ...

随机推荐

  1. C++Primer 5th Chap2 Variables and basic Types

    wchar_t,char16_t,char32_t用于拓展字符集 char和signed char并不一样,由编译器决定类型char表现上述两种中的哪一种 一般long的大小和int无二,如果超过in ...

  2. python学习-61 类

    类 (在python2里) 1.属性 ---数据属性 ---函数属性 查看属性字典 class chinese: rz:'huangzhong' print(chinese.__dict__) 运行结 ...

  3. python基础 — Mysql Server

    sql server对于字符类型的有:char:固定长度,存储ANSI字符,不足的补英文半角空格.nchar:固定长度,存储Unicode字符,不足的补英文半角空格varchar:可变长度,存储ANS ...

  4. TZOJ5255: C++实验:三角形面积

    #include<iostream> #include<iomanip> #include<math.h> #include<cmath> using ...

  5. docker深入学习一

    docker是一个客户服务器结构的应用程序,其结构如下所示 其组成部分包括 container容器:是image的运行实例,一般container之间以及container与主机之间是相互隔离的,相当 ...

  6. leetcode两数相加

    题目描述:给出两个 非空 的链表用来表示两个非负的整数.其中,它们各自的位数是按照 逆序 的方式存储的,并且它们的每个节点只能存储 一位 数字. 如果,我们将这两个数相加起来,则会返回一个新的链表来表 ...

  7. openstack-nova源码之创建虚拟机

    1.nova/api/openstack/compute/servers.py  create() 在create函数前面包含三种装饰器,分别为:@wsgi.response.@wsgi.expect ...

  8. 【C#】课堂知识点#4

    1.回顾类中基本结构. 成员分为: a.(数据成员) , b.(方法成员) 数据成员: 字段 方法成员:方法,构造函数,属性,索引器,运算符. 属性的作用: 对字段进行访问提供get,set方法. 类 ...

  9. Python Django 协程报错,进程池、线程池与异步调用、回调机制

    一.问题描述 在Django视图函数中,导入 gevent 模块 import gevent from gevent import monkey; monkey.patch_all() from ge ...

  10. 机器学习 降维算法: isomap & MDS

    最近在看论文的时候看到论文中使用isomap算法把3D的人脸project到一个2D的image上.提到降维,我的第一反应就是PCA,然而PCA是典型的线性降维,无法较好的对非线性结构降维.ISOMA ...