如何验证从.net核心应用程序中的网站收到的证书

时间:2017-03-01 09:33:57

标签: c# certificate .net-core

我正在开发一个.net核心应用程序,向Trello的网站发出REST请求。但是,在第一次请求时,我收到了TlsException: Invalid certificate received from server

在Google上搜索此错误后,我找到了一种使用ServicePointManager.ServerCertificateValidationCallback方法的解决方法。我的问题是ServicePointManager不是.net核心的一部分。验证Trello证书或在我的环境中完全绕过验证步骤的正确方法是什么?

以下是相关的异常堆栈跟踪:

TlsException: Invalid certificate received from server. Error code: 0xffffffff80092012
Mono.Security.Protocol.Tls.Handshake.Client.TlsServerCertificate.validateCertificates (Mono.Security.X509.X509CertificateCollection certificates)
Mono.Security.Protocol.Tls.Handshake.Client.TlsServerCertificate.ProcessAsTls1 ()
Mono.Security.Protocol.Tls.Handshake.HandshakeMessage.Process ()
(wrapper remoting-invoke-with-check) Mono.Security.Protocol.Tls.Handshake.HandshakeMessage:Process ()
Mono.Security.Protocol.Tls.ClientRecordProtocol.ProcessHandshakeMessage (Mono.Security.Protocol.Tls.TlsStream handMsg)
Mono.Security.Protocol.Tls.RecordProtocol.InternalReceiveRecordCallback (IAsyncResult asyncResult)
Rethrow as IOException: The authentication or decryption has failed.
Mono.Security.Protocol.Tls.SslStreamBase.AsyncHandshakeCallback (IAsyncResult asyncResult)
Rethrow as WebException: Error getting response stream (Write: The authentication or decryption has failed.): SendFailure
System.Net.HttpWebRequest.EndGetResponse (IAsyncResult asyncResult)
System.Net.HttpWebRequest.GetResponse ()
RestSharp.Http.GetRawResponse (System.Net.HttpWebRequest request)
Rethrow as WebException: Trello returned with an error.
Error Message: Error getting response stream (Write: The authentication or decryption has failed.): SendFailure

0 个答案:

没有答案