我有一个用 .NET Core 编写的服务,它在 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 容器或主机吗?)
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
我是一名优秀的程序员,十分优秀!