twolf twolf - 5 days ago 6
Android Question

How do I enable TLSv1.1+ on Xamarin Android (API 16 - 19)?

I am trying to enable TLSv1.1 or TLSv1.2 for my Android app (which is built using Xamarin). Android API 16+ supports both 1.1 & 1.2, but are not enabled by default until API 20 (source). Can anyone explain how to enable TLSv1.1 or TLSv1.2, and use it with .Net's HttpClient (or recommend an alternative to HttpClient).

Answer

Install Google Play Services - Safety Net
and call

if (Android.OS.Build.VERSION.SdkInt <= BuildVersionCodes.Kitkat)
{
    ProviderInstaller.InstallIfNeededAsync(ApplicationContext, this);
}

InstallIfNeeded will enable tls1.1+ usage. It is required once per application start. Next - you need to use native HttpMessageHandler for HttpClient, see ModernHttpClient

Comments