Mac上运行的dotnet核心上的X509Chain错误

时间:2018-10-02 22:28:45

标签: c# .net macos ssl core

我已经使用.net core 2.1和C#开发了一个应用程序,在此应用程序中,我在Windows版本中通过HTTPS(SSL)调用了API,自包含应用程序可以正常运行,但在Mac上出现以下错误:

  

System.Net.Http.HttpRequestException:无法建立SSL连接   建立,请参阅内部异常。 ->   System.PlatformNotSupportedException:X509Chain位于   Internal.Cryptography.Pal.SecTrustChainPal.PreparePoliciesArray(Boolean   checkRevocation)   内部密码术Pal.SecTrustChainPal.OpenTrustHandle(ICertificatePal   leafCert,X509Certificate2Collection extraStore,X509RevocationMode   revocationMode)   Internal.Cryptography.Pal.ChainPal.BuildChain(布尔   useMachineContext,ICertificatePal证书,X509Certificate2Collection   extraStore,OidCollection应用程序策略,OidCollection   certificatePolicy,X509RevocationMode吊销模式,   X509RevocationFlag revocationFlag,DateTime验证时间,TimeSpan   超时)   System.Security.Cryptography.X509Certificates.X509Chain.Build(X509Certificate2   证书,布尔throwOnException),位于   System.Security.Cryptography.X509Certificates.X509Chain.Build(X509Certificate2   证书)   System.Net.CertificateValidationPal.VerifyCertificateProperties(SafeDeleteContext   securityContext,X509Chain链,X509Certificate2 remoteCertificate,   布尔值checkCertName,布尔值isServer,字符串hostName)位于   System.Net.Security.SecureChannel.VerifyRemoteCertificate(RemoteCertValidationCallback   remoteCertValidationCallback,ProtocolToken&alertToken),位于   System.Net.Security.SslState.CompleteHandshake(ProtocolToken&   alertToken)在   System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken   消息,AsyncProtocolRequest asyncRequest)   System.Net.Security.SslState.StartSendBlob(Byte []传入,Int32   计数,AsyncProtocolRequest asyncRequest)   System.Net.Security.SslState.ProcessReceivedBlob(Byte []缓冲区,Int32   计数,AsyncProtocolRequest asyncRequest)   System.Net.Security.SslState.StartReadFrame(Byte []缓冲区,Int32   readBytes,AsyncProtocolRequest asyncRequest)   System.Net.Security.SslState.PartialFrameCallback(AsyncProtocolRequest   asyncRequest)   ---从先前抛出异常的位置开始的堆栈跟踪---位于System.Net.Security.SslState.ThrowIfExceptional()
  在   System.Net.Security.SslState.InternalEndProcessAuthentication(LazyAsyncResult   lazyResult)   System.Net.Security.SslState.EndProcessAuthentication(IAsyncResult   结果)   System.Net.Security.SslStream.EndAuthenticateAsClient(IAsyncResult   asyncResult)   System.Net.Security.SslStream。<> c.b__47_1(IAsyncResult   )   System.Threading.Tasks.TaskFactory 1.FromAsyncCoreLogic(IAsyncResult iar, Func 2 endFunction,操作1 endAction, Task 1承诺,布尔值   需要同步)   ---从上一个引发异常的位置开始的堆栈跟踪-   System.Net.Http.ConnectHelper。EstablishmentSslConnectionAsyncCore(流   流,SslClientAuthenticationOptions sslOptions,CancellationToken   cancelToken)

1 个答案:

答案 0 :(得分:0)

我在以下stackOverflow中的以下帖子中找到了解决此问题的方法

Ignore bad certificate - .NET CORE