[英]How to ignore SSL certificate validation in .Net-Core 2 on CentOS
我正在使用.NetCore 2.0構建控制台應用程序
此應用程序正在對在“ https”上運行但其證書無效的服務器進行REST調用。 為了支持此問題,我重寫了“ ServerCertificateCustomValidationCallback ”函數:
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 Core應用程序在Windows 10上運行良好。但是,當我在CentOS 7(1511版)上運行它時,出現此錯誤:
System.PlatformNotSupportedException:處理程序不支持使用libcurl(7.29.0)及其SSL后端(“ NSS / 3.19.1 Basic ECC”)的這種組合來對證書進行自定義處理。 在System.Net.Http.CurlHandler.EasyRequest.System.Net.Http.CurlHandler.SslProvider.SetSslOptions(EasyRequest容易,ClientCertificateOption clientCertOption)的System.Net.Http.CurlHandler.SslProvider.SetSslOptionsForUnsupportedBackend(EasyRequest easy,ClientCertificateProvider certProvider) ()在System.Net.Http.CurlHandler.MultiAgent.ActivateNewRequest(EasyRequest easy)-從上一個引發異常的位置開始的堆棧跟蹤-
是.NetCore中的錯誤?
我應該在CentOS中更新一些庫嗎? 我可以使用在CentOS中可用的替代代碼嗎?
通過下載較新版本的“ 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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.