簡體   English   中英

X509CertificateValidationMode在Linux中不起作用?

[英]X509CertificateValidationMode not working in Linux?

我有一個用.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

該錯誤與.NET Core不允許SSL(支持TLS)有關。

對於舊版互操作,我在這里提出了一個問題

https://github.com/dotnet/wcf/issues/1749

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM