分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > IT知识

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

发布时间:2023-09-06 01:32责任编辑:赖小花关键词:http

当前系统环境: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#备份原来的curlmv /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

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

原文地址:http://www.cnblogs.com/calvinK/p/8086046.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved