Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cocoa/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# X509CertificateValidationMode在Linux中不工作?_C#_Linux_Wcf_Docker_.net Core - Fatal编程技术网

C# X509CertificateValidationMode在Linux中不工作?

C# X509CertificateValidationMode在Linux中不工作?,c#,linux,wcf,docker,.net-core,C#,Linux,Wcf,Docker,.net Core,我有一个用.NETCore编写的服务,它在Windows上运行得非常出色,但在Ubuntu或docker官方镜像上运行时,除了问题末尾的例外,它无法运行。在所有平台上的所有情况下都使用“dotnet Asgard.Ihc.Api.dll”。我也在1.1.0版的任何地方 我的代码是一个WCF客户机,它使用无效证书调用旧的SOAP/XML服务。为了解决这个问题,我补充道: client.ClientCredentials.ServiceCertificate.SslCertificateAuthen

我有一个用.NETCore编写的服务,它在Windows上运行得非常出色,但在Ubuntu或docker官方镜像上运行时,除了问题末尾的例外,它无法运行。在所有平台上的所有情况下都使用“dotnet Asgard.Ihc.Api.dll”。我也在1.1.0版的任何地方

我的代码是一个WCF客户机,它使用无效证书调用旧的SOAP/XML服务。为了解决这个问题,我补充道:

client.ClientCredentials.ServiceCertificate.SslCertificateAuthentication = new X509ServiceCertificateAuthentication()
    {
        CertificateValidationMode = X509CertificateValidationMode.None,
        RevocationMode = X509RevocationMode.NoCheck
    };
然而,根据例外情况判断,我最好的猜测是上面的代码在Linux上不起作用

有人能证实或否认我的怀疑吗

我能解决这个问题吗?(我可以将证书添加到docker容器或主机吗?)

未处理的异常:System.AggregateException:发生一个或多个错误。
(发送请求时出错。)-->
System.ServiceModel.CommunicationException:发送请求时出错。-->
System.Net.Http.HttpRequestException:发送请求时出错。-->
System.Net.Http.Exception:SSL连接错误
位于System.Net.Http.CurlHandler.ThrowIfCURLEError(CURLcode错误)
位于System.Net.Http.CurlHandler.MultiAgent.FinishRequest(strongTowakReference`1 EasyRapper,CURLcode messageResult)
---内部异常堆栈跟踪的结束---
在System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()中
在System.Runtime.CompilerServices.TaskWaiter.HandleNonSuccessAndDebuggerNotification(任务任务)中
在System.ServiceModel.Channels.ServiceModelHttpMessageHandler.d__37.MoveNext()中
---来自引发异常的上一个位置的堆栈结束跟踪---
在System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()中
在System.Runtime.CompilerServices.TaskWaiter.HandleNonSuccessAndDebuggerNotification(任务任务)中
在System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()中
在System.Net.Http.HttpClient.d_u58.MoveNext()上
---来自引发异常的上一个位置的堆栈结束跟踪---
在System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()中
在System.Runtime.CompilerServices.TaskWaiter.HandleNonSuccessAndDebuggerNotification(任务任务)中
位于System.ServiceModel.Channels.HttpChannelFactory`1.HttpClientRequestChannel.HttpClientChannelAsyncRequest.d_u13.MoveNext()
---内部异常堆栈跟踪的结束---
在System.Runtime.AsyncResult.End[TAsyncResult](IAsyncResult结果)
位于System.ServiceModel.Channel.ServiceChannel.SendAsyncResult.End(SendAsyncResult)
位于System.ServiceModel.Channels.ServiceChannel.EndCall(字符串操作,对象[]输出,IAsyncResult结果)
在System.ServiceModel.Channels.ServiceChannelProxy.TaskCreator.c\uu DisplayClass1\u 0.b\uu 0(IAsyncResult asyncResult)
---来自引发异常的上一个位置的堆栈结束跟踪---
在System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()中
在System.Runtime.CompilerServices.TaskWaiter.HandleNonSuccessAndDebuggerNotification(任务任务)中
在System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()中
在/home/tvl/Asgard.Ihc.Api/src/Asgard.Ihc.Controller/IhcController.d_u15.MoveNext()中
---内部异常堆栈跟踪的结束---
位于System.Threading.Tasks.Task.ThrowifeException(布尔值IncludeTaskCanceledException)
在System.Threading.Tasks.Task.Wait(Int32毫秒计时,CancellationToken CancellationToken)
在System.Threading.Tasks.Task.Wait()中
在/home/tvl/Asgard.Ihc.Api/src/Asgard.Ihc.Api/IhcMonitor.cs中的Asgard.Ihc.Api.IhcMonitor.Start()处:第23行
在/home/tvl/Asgard.Ihc.Api/src/Asgard.Ihc.Api/Program.cs中的Asgard.Ihc.Api.Main(字符串[]args)处:第18行

该错误与.NET Core不允许SSL(支持TLS)有关

对于遗留互操作,我在这里提出了一个问题

Unhandled Exception: System.AggregateException: One or more errors occurred.
(An error occurred while sending the request.) ---> 
System.ServiceModel.CommunicationException: An error occurred while sending the request. ---> 
System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> 
System.Net.Http.CurlException: SSL connect error
at System.Net.Http.CurlHandler.ThrowIfCURLEError(CURLcode error)
at System.Net.Http.CurlHandler.MultiAgent.FinishRequest(StrongToWeakReference`1 easyWrapper, CURLcode messageResult)
--- End of inner exception stack trace ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.ServiceModel.Channels.ServiceModelHttpMessageHandler.<SendAsync>d__37.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
at System.Net.Http.HttpClient.<FinishSendAsync>d__58.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.ServiceModel.Channels.HttpChannelFactory`1.HttpClientRequestChannel.HttpClientChannelAsyncRequest.<SendRequestAsync>d__13.MoveNext()
--- End of inner exception stack trace ---
at System.Runtime.AsyncResult.End[TAsyncResult](IAsyncResult result)
at System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.End(SendAsyncResult result)
at System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result)
at System.ServiceModel.Channels.ServiceChannelProxy.TaskCreator.<>c__DisplayClass1_0.<CreateGenericTask>b__0(IAsyncResult asyncResult)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at Asgard.Ihc.Controller.IhcController.<Connect>d__15.MoveNext() in /home/tvl/Asgard.Ihc.Api/src/Asgard.Ihc.Controller/IhcController.cs:line 72
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at System.Threading.Tasks.Task.Wait()
at Asgard.Ihc.Api.IhcMonitor.Start() in /home/tvl/Asgard.Ihc.Api/src/Asgard.Ihc.Api/IhcMonitor.cs:line 23
at Asgard.Ihc.Api.Program.Main(String[] args) in /home/tvl/Asgard.Ihc.Api/src/Asgard.Ihc.Api/Program.cs:line 18