解决linux netcore https请求使用自签名证书忽略安全检查方法

简介: 当前系统环境:centos7 x64. dotnet 2.0.不管是ServicePointManager.ServerCertificateValidationCallback = (a, b, c, d) => true;还是:HttpClient httpClient = new Ht...

当前系统环境:centos7 x64. dotnet 2.0.
不管是
ServicePointManager.ServerCertificateValidationCallback = (a, b, c, d) => true;
还是:
HttpClient httpClient = new HttpClient(new HttpClientHandler() { ServerCertificateCustomValidationCallback = (a, b, c, d) => true });

都会发生错误:
错误信息大致如下:
(The handler does not support custom handling of certificates with this combination of libcurl (7.29.0) and its SSL backend ("NSS/3.28.4").) ---> System.PlatformNotSupportedException: The handler does not support custom handling of certificates with this combination of libcurl (7.29.0) and its SSL backend ("NSS/3.28.4").
at System.Net.Http.CurlHandler.SslProvider.SetSslOptionsForUnsupportedBackend(EasyRequest easy, ClientCertificateProvider certProvider)
at System.Net.Http.CurlHandler.SslProvider.SetSslOptions(EasyRequest easy, ClientCertificateOption clientCertOption)

解决方案:

# yum update(可选)
# yum install openssl-devel gcc #安装openssl和gcc

# 安装指定版本的curl
# wget https://curl.haxx.se/download/curl-7.55.1.tar.gz
# tar -zxf curl-7.55.1.tar.gz
# cd curl-7.55.1
# ./configure --prefix=/usr/local/curl/ --without-nss --with-ssl=/usr/local/ssl/
# make
# make install

#备份原来的curl
mv /usr/bin/curl /usr/bin/curl.bak

#将安装的curl 创建软连
ln -s /usr/local/curl/bin/curl /usr/bin/curl
#  curl --version
#差不多输出下面的内容
#curl 7.55.1 (x86_64-pc-linux-gnu) libcurl/7.55.1 OpenSSL/1.0.2k zlib/1.2.7

#增加lib搜索目录
# vi /etc/ld.so.conf 
#增加
# /usr/local/curl/lib
# cat /etc/ld.so.conf 
差不多下面这样子
#
include ld.so.conf.d/*.conf
/usr/local/curl/lib

# 重新load配置
# ldconfig

参考文章:
https://www.latoooo.com/xia_zhe_teng/368.htm
https://segmentfault.com/a/1190000012282935
https://www.cnblogs.com/Anker/p/3209876.html
https://github.com/dotnet/corefx/issues/9728#issuecomment-286251370

目录
相关文章
|
21天前
|
Linux Shell Windows
Linux如何检查文件夹的大小?
在Linux中查看文件夹大小,可使用`du`(如`du -sh *`)、`df`(如`df -h /home`)查看磁盘使用情况,`ncdu`提供交互式浏览,`ls -lh`显示当前目录文件大小,`find`与`du`结合找大文件夹,`tree --du -h`展示目录结构及大小,或用`awk`与`du`组合按大小排序。不同场景下,这些命令各有优势。
147 1
Linux如何检查文件夹的大小?
|
2月前
|
安全 搜索推荐 前端开发
揭秘 HTTPS 加密协议:保护你的网上安全之道
揭秘 HTTPS 加密协议:保护你的网上安全之道
126 0
|
2月前
|
Linux
linux 常用内存检查命令
linux 常用内存检查命令
43 0
|
1月前
|
安全 Shell Linux
【Shell 命令集合 磁盘维护】Linux 检查和修复Minix文件系统 fsck.minix命令使用教程
【Shell 命令集合 磁盘维护】Linux 检查和修复Minix文件系统 fsck.minix命令使用教程
13 0
|
1月前
|
存储 监控 Shell
【Shell 命令集合 磁盘管理 】Linux 检查磁盘空间限制的状态 repquota命令使用指南
【Shell 命令集合 磁盘管理 】Linux 检查磁盘空间限制的状态 repquota命令使用指南
30 0
|
1月前
|
算法 Shell Linux
【Shell 命令集合 文档编辑】Linux 检查文本文件中的拼写错误 spell 命令使用指南
【Shell 命令集合 文档编辑】Linux 检查文本文件中的拼写错误 spell 命令使用指南
34 0
|
1月前
|
算法 Shell Linux
【Shell 命令集合 磁盘维护 】Linux 检查和修复文件系统错误 fsck命令使用教程
【Shell 命令集合 磁盘维护 】Linux 检查和修复文件系统错误 fsck命令使用教程
25 0
|
14天前
|
关系型数据库 MySQL Linux
linux CentOS 7.4下 mysql5.7.20 密码改简单的方法
linux CentOS 7.4下 mysql5.7.20 密码改简单的方法
17 0
|
21天前
|
Ubuntu Linux
常用Linux开机启动添加方法
常用Linux开机启动添加方法
14 1
|
1月前
|
安全 Linux 开发者
⭐⭐⭐⭐⭐Linux C/C++ 进程崩溃诊断以及有效数据收集:解锁代码问题快速定位与修复的方法
⭐⭐⭐⭐⭐Linux C/C++ 进程崩溃诊断以及有效数据收集:解锁代码问题快速定位与修复的方法
80 1