[MonoTouch] Invalid Certificate received from server

Gonzalo Paniagua Javier gonzalo.mono at gmail.com
Wed Mar 21 01:34:28 UTC 2012


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