Forum Xamarin Xamarin.Android

https connections with android failing

slycoderslycoder USMember
edited December 2016 in Xamarin.Android

I'm using a self signed cert and trying to connect to a local server via https. Here's my code:


        using (HttpClient client = new HttpClient(new ModernHttpClient.NativeMessageHandler(false, true) { ClientCertificateOptions = ClientCertificateOption.Manual, }, false))

            text = await client.GetStringAsync(address);


ServicePointManager.ServerCertificateValidationCallback += 
            (sender, certificate, chain, errors) => certificate.GetCertHashString() == "abc123";

The callback is never called. When a do a GET with the client, it throws an exception which is null and gives me no info. This shows in the log which is normal i think:

12-08 08:40:43.175 D/NetworkSecurityConfig( 5796): No Network Security Config specified, using platform default

I'm deploying the app on my google pixel xl with nougat. I tried with a version 6.0 emulator, no luck. i get this:

12-08 08:50:42.137 D/ ( 1428): HostConnection::get() New Host Connection established 0x99f44ac0, tid 1457
12-08 08:50:42.149 I/OpenGLRenderer( 1428): Initialized EGL, version 1.4
12-08 08:50:42.199 W/EGL_emulation( 1428): eglSurfaceAttrib not implemented
12-08 08:50:42.199 W/OpenGLRenderer( 1428): Failed to set EGL_SWAP_BEHAVIOR on surface 0x9b868b60, error=EGL_SUCCESS
12-08 08:50:42.557 D/Mono ( 1428): DllImport searching in: '__Internal' ('(null)').

Both devices crash at the same place at GET.
The above code works fine on my wpf client. Does android have some special flags I need to set?



  • BerayBentesenBerayBentesen TRUniversity ✭✭✭✭

    In Android project settings change default handler to native client handler

Sign In or Register to comment.