我正在制作一个简单的 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 失败并显示“身份验证或解密失败"
发布评论