Reputation: 2660
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
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.
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.
Upvotes: 3
Views: 3081
Reputation: 320
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.
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
);
or a bit shorter
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 :-)
Upvotes: 4