Mono https webrequest 失败并显示“身份验证或解密失败"

编程入门 行业动态 更新时间:2024-10-07 14:30:08
本文介绍了Mono https webrequest 失败并显示“身份验证或解密失败"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在制作一个简单的 REST 客户端以在我的 C# 应用程序中使用.在 Windows 上的 中,它适用于 和 连接.在 Ubuntu 10.10 上的 mono 2.6.7(也用 2.8 测试,结果相同)只有 有效.连接在 request.GetResponse() 方法上抛出此异常:

I'm making a simple REST client to use in my C# applications. In on Windows It works great with and connections. In mono 2.6.7 (Also tested with 2.8 with the same results) on Ubuntu 10.10 only works. connections throw up this exception on the request.GetResponse() method:

Unhandled Exception: System.Net.WebException: Error getting response stream (Write: The authentication or decryption has failed.): SendFailure ---> System.IO.IOException: The authentication or decryption has failed. ---> Mono.Security.Protocol.Tls.TlsException: Invalid certificate received from server. Error code: 0xffffffff800b010a at Mono.Security.Protocol.Tls.Handshake.Client.TlsServerCertificate.validateCertificates (Mono.Security.X509.X509CertificateCollection certificates) [0x00000] in <filename unknown>:0 at Mono.Security.Protocol.Tls.Handshake.Client.TlsServerCertificate.ProcessAsTls1 () [0x00000] in <filename unknown>:0 at Mono.Security.Protocol.Tls.Handshake.HandshakeMessage.Process () [0x00000] in <filename unknown>:0 at (wrapper remoting-invoke-with-check) Mono.Security.Protocol.Tls.Handshake.HandshakeMessage:Process () at Mono.Security.Protocol.Tls.ClientRecordProtocol.ProcessHandshakeMessage (Mono.Security.Protocol.Tls.TlsStream handMsg) [0x00000] in <filename unknown>:0 at Mono.Security.Protocol.Tls.RecordProtocol.InternalReceiveRecordCallback (IAsyncResult asyncResult) [0x00000] in <filename unknown>:0 --- End of inner exception stack trace --- at Mono.Security.Protocol.Tls.SslStreamBase.AsyncHandshakeCallback (IAsyncResult asyncResult) [0x00000] in <filename unknown>:0 --- End of inner exception stack trace --- at System.Net.HttpWebRequest.EndGetResponse (IAsyncResult asyncResult) [0x00000] in <filename unknown>:0 at System.Net.HttpWebRequest.GetResponse () [0x00000] in <filename unknown>:0

我还没有找到任何方法来解决这个问题.任何人都知道为什么会发生这种情况以及如何解决它?

I haven't been able to find any way to fix this. Anyone have any idea why this is happening and how to fix it?

同样,这仅在 Mono 中失败,.Net 建立连接似乎没有任何问题.

Again, this only fails in Mono, .Net doesn't seem to have any problem establishing a connection.

这是调用代码:

public JToken DoRequest(string path, params string[] parameters) { if(!path.StartsWith("/")) { path = "/" + path; } string fullUrl = url + path + ToQueryString(parameters); if(DebugUrls) Console.WriteLine("Requesting: {0}", fullUrl); WebRequest request = HttpWebRequest.CreateDefault(new Uri(fullUrl)); using(WebResponse response = request.GetResponse()) using(Stream responseStream = response.GetResponseStream()) { return ReadResponse(responseStream); } }

推荐答案

Mono 默认不信任任何证书,要导入 Mozilla 信任的根权限可以运行 mozroots --import --quiet在mozroots.exe所在的mono安装文件夹中

Mono does not trust any certificate by default, to import the Mozilla trusted root authorities you can run mozroots --import --quiet in the mono installation folder where mozroots.exe is located

更多推荐

Mono https webrequest 失败并显示“身份验证或解密失败"

本文发布于:2023-11-24 00:52:58,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1623370.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:身份验证   https   Mono   quot   webrequest

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!