Enable tls 1.2 Android 4.X - Xamarin Android -

I need to enable the TLS 1.2 on devices before 5.0 version. I implemented the TLSSocketFactory:

TlSSocketFactory implementation

and I implemented the AndroidCustomClientHandler

AndroidCustomClientHandler

My request to the server is:

\_client.SendAsync(aRequest, cancellationToken.Token);

the aRequest is type of HttpRequestMessage.

i receive an exception:

Javax.Net.Ssl.SSLHandshakeException:java.security.cert.CertPathValidatorException:Trust anchor for` . certification path not found. ---\>`Java.Security.Cert.CertificateException:java.security.cert.CertPathValidatorException:Trust anchor for certification path not found.---\>Java.Security.Cert.CertPathValidatorException:Trust anchor for certification path not found.---End of inner exception stack trace ------End of inner exception stack trace --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()[0x0000c]in\<f32579baafc1404fa37ba3ec1abdc0bd\>:0 at Java.Interop.JniEnvironment+InstanceMethods.CallVoidMethod(Java.Interop.JniObjectReference instance,Java.Interop.JniMethodInfo method,Java.Interop.JniArgumentValue\* args)[0x00069]in\<7802aa64ad574c33adca332a3fa9706a\>:0 at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeAbstractVoidMethod(System.String encodedMember,Java.Interop.IJavaPeerableself,Java.Interop.JniArgumentValue\* parameters)[0x00014]in\<7802aa64ad574c33adca332a3fa9706a\>:0 at Javax.Net.Ssl.HttpsURLConnectionInvoker.Connect()[0x00000]in/Users/builder/data/lanes/5945/dffc5912/source/monodroid/external/xamarin-android/src/Mono.Android/obj/Release/android-26/mcw/Javax.Net.Ssl.HttpsURLConnection.cs:417 at Xamarin.Android.Net.AndroidClientHandler+\<\>c\_\_DisplayClass42\_0.\<ConnectAsync\>b\_\_0 ()[0x0005a]in/Users/builder/data/lanes/5945/dffc5912/source/monodroid/external/xamarin-android/src/Mono.Android/Xamarin.Android.Net/AndroidClientHandler.cs:308 at System.Threading.Tasks.Task.InnerInvoke()[0x0000f]in\<f32579baafc1404fa37ba3ec1abdc0bd\>:0 at System.Threading.Tasks.Task.Execute()[0x00010]in\<f32579baafc1404fa37ba3ec1abdc0bd\>:0---End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()[0x0000c]in\<f32579baafc1404fa37ba3ec1abdc0bd\>:0 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task task)[0x0003e]in\<f32579baafc1404fa37ba3ec1abdc0bd\>:0 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task task)[0x00028]in\<f32579baafc1404fa37ba3ec1abdc0bd\>:0 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(System.Threading.Tasks.Task task)[0x00008]in\<f32579baafc1404fa37ba3ec1abdc0bd\>:0 at System.Runtime.CompilerServices.ConfiguredTaskAwaitable+ConfiguredTaskAwaiter.GetResult()[0x00000]in\<f32579baafc1404fa37ba3ec1abdc0bd\>:0 at Xamarin.Android.Net.AndroidClientHandler+\<DoProcessRequest\>d\_\_44.MoveNext()[0x000e4]in/Users/builder/data/lanes/5945/dffc5912/source/monodroid/external/xamarin-android/src/Mono.Android/Xamarin.Android.Net/AndroidClientHandler.cs:357

How can I solve the problem?? Many Thanks.

Hi @domdp16,

This post was moved to a different board that fits your topic of discussion a bit better. This means you’ll get better engagement on your post, and it keeps our community organized so users can more easily find information.

As you’ll notice, your topic is now here in the Project Development Help and Advice board. No action is needed on your part; you can continue the conversation as normal here.

Cheers!