[MonoTouch] Invalid Certificate received from server

Dean Cleaver dean.cleaver at xceptionsoftware.com
Wed Mar 21 01:40:13 UTC 2012


Thanx Gonzalo - have done exactly that, and it's working. And yes - I tried the site in Safari on the iPhone and it worked, but I'm definitely getting MonoTouch TLS errors in code.

Dino

-----Original Message-----
From: Gonzalo Paniagua Javier [mailto:gonzalo.mono at gmail.com] 
Sent: Tuesday, March 20, 2012 8:34 PM
To: Dean Cleaver
Cc: monotouch at lists.ximian.com
Subject: Re: [MonoTouch] Invalid Certificate received from server

On Tue, Mar 20, 2012 at 7:55 PM, Dean Cleaver <dean.cleaver at xceptionsoftware.com> wrote:
> Hi,
>
> I’m having trouble with using Braintree Payments gateway because of an 
> apparent invalid certificate returned from server. Everything works 
> fine to their sandbox, but not to production, and they are 2 different 
> issuers (and
> levels) of certificate:
>
> https://sandbox.braintreegateway.com
>
> https://www.braintreegateway.com
>
> The iPhone itself seems to trust the www.braintreegateway.com one when 
> I use Safari, but the Braintree C# API code is failing when I try it in MonoTouch.
> Works fine to the Sandbox one.
>
> Any ideas what could be the cause?

If you can browse with Safari on the iphone to those sites without getting a certificate warning, it should work fine...

While someone figures out what the real problem is, you can add this line to your code before using any System.Net code to workaround the
problem:

     ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback ((a, b, c, d) => { return true; });

-Gonzalo


More information about the MonoTouch mailing list