我正在使用.NetCore 2.0构建一个控制台应用程序
此应用程序正在对运行在"ServerCertificateCustomValidationCallback“”https“上的服务器进行REST调用,但该服务器的证书无效。为了支持此问题,我重写了函数:
HttpClientHandler httpClientHandler;
if (IgnoreSslErrors)
{
httpClientHandler = new HttpClientHandler
{
ServerCertificateCustomValidationCallback = (message, certificate2, chain, errors) =>
{
Log.Warn($"Invalid SSL/TLS server certificate: {errors}");
return true;
}
};
}
else
{
httpClientHandler = new HttpClientHandler();
}
HttpClient httpClient = new HttpClient(httpClientHandler, true);这个.net核心应用程序在Windows 10上工作得很好。但是当我在CentOS 7 (1511版本)上运行它时,我得到了以下错误:
System.PlatformNotSupportedException:该处理程序不支持使用libcurl (7.29.0)及其SSL后端("NSS/3.19.1 Basic“)组合自定义证书处理。在System.Net.Http.CurlHandler.SslProvider.SetSslOptionsForUnsupportedBackend(EasyRequest轻松,ClientCertificateProvider certProvider(在System.Net.Http.CurlHandler.SslProvider.SetSslOptions(EasyRequest轻松),ClientCertificateOption clientCertOption(在System.Net.Http.CurlHandler.EasyRequest.InitializeCurl() at System.Net.Http.CurlHandler.MultiAgent.ActivateNewRequest(EasyRequest轻松)--从抛出异常的前一个位置开始的堆栈跟踪的结束--
是.NetCore中的一个bug吗?
我应该更新CentOS中的一些库吗?我可以使用在CentOS中工作的替代代码吗?
发布于 2017-09-13 06:53:49
通过下载更新版本的"libcurl-openssl“,在CentOS中解决了这个问题
'yum install libcurl-openssl-7.43.0-1.1.x86_64.rpm'然后重定向powershell以发现新的动态库。
set LD_LIBRARY_PATH=/opt/shibboleth/lib64/:$LD_LIBRARY_PATH*如果您将应用程序作为服务运行,请确保将其添加到“服务”部分下的".service“文件中:
Environment=LD_LIBRARY_PATH=/opt/shibboleth/lib64/:$LD_LIBRARY_PATH更详细的资料可在这些职位上查阅:
https://issues.couchbase.com/browse/NCBC-1296 https://github.com/PowerShell/PowerShell/issues/2511
https://stackoverflow.com/questions/46178308
复制相似问题