twolf twolf - 1 year ago 130
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 Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download