从服务器xamarin.android收到的证书无效 [英] Invalid certificate received from server xamarin.android

查看:107
本文介绍了从服务器xamarin.android收到的证书无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以这让我抓狂了1天了.我正在尝试与xamarin.android上的REST API通讯,但由于某些原因,我收到此错误:

So this is driving me crazy for 1 day now. I'm trying to talk to a REST API on xamarin.android but for some reason I get this error:


InnerException  {Mono.Security.Protocol.Tls.TlsException: Invalid
certificate received from server. Error code: 0xffffffff800b010a   at
Mono.Security.Protocol.Tls.Handshake.Client.TlsServerCertificate.RemoteValidation
(Mono.Security.Protocol.Tls.ClientContext context, AlertDescription
description) [0x00000] in :0    at
Mono.Security.Protocol.Tls.Handshake.Client.TlsServerCertificate.validateCertificates
(Mono.Security.X509.X509CertificateCollection certificates) [0x00000]
in :0    at
Mono.Security.Protocol.Tls.Handshake.Client.TlsServerCertificate.ProcessAsTls1
() [0x00000] in :0    at
Mono.Security.Protocol.Tls.Handshake.HandshakeMessage.Process ()
[0x00000] in :0    at
Mono.Security.Protocol.Tls.ClientRecordProtocol.ProcessHandshakeMessage
(Mono.Security.Protocol.Tls.TlsStream handMsg) [0x00000] in :0    at
Mono.Security.Protocol.Tls.RecordProtocol.InternalReceiveRecordCallback
(IAsyncResult asyncResult) [0x00000] in :0
}   Mono.Security.Protocol.Tls.TlsException

经过一些研究,我发现这与我正在与之交谈的服务器缺少证书有关(如果我错了,请更正我).因此,我在Mac上的钥匙串中添加了SSL证书.我还运行了Mozilla命令以安装默认证书.

After some research I found that this has to do with the missing certificate from the server I'm talking to (correct me if I'm wrong). So I added the SSL certificate to keychain on my Mac. I also ran the Mozilla command for installing the default certificates.

不幸的是,这仍然行不通.在Windows上,与API的连接就像一个超级按钮.据我了解,这是因为Windows拥有自己的CA存储区和一些默认证书.

Unfortunately this still not works. On windows the connection with the API works like a charm. From what I read this is because windows got its own CA store and some default certificates.

推荐答案

我遇到了与您相同的问题,就我而言,我实际上设法确定我的证书名与匹配项不符.我不知道该怎么解决,因为这不是我的服务器,而是我要从中请求数据.

I'm having the same issues as you do, in my case I actually managed to figure out I had a certificatename-missmatch. Something I don't know how to solve, as it's not my server I am requesting data from.

到目前为止,我使用的一种变通方法是压制所有SLL,并使用以下代码接受其中的所有内容:

A work-around for development I used so far is to surpress all SLL, and just accept all there is using the following code:

                ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback
                (
                    (srvPoint, certificate, chain, errors) => true
                );

或更短

ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(delegate { return true; });

但是,请注意,这不是解决问题的方法,而只是一种变通方法,因此您可以继续进行开发.

However, take note that this is not THE solution to the problem, but just a work-around so you can continue developing.

我希望这对您有所帮助,并且您现在就可以意识到这个令人讨厌的异常:-)

I hope this helps you out, and you can get your mind of this nasty exception for now :-)

这篇关于从服务器xamarin.android收到的证书无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆