简体   繁体   中英

How to enable TLS 1.2 support in an Xamarin Android application C#

I'm developing a Xamarin project. With the help of C# code, I need to access the azure API for my project. It produces the following error 'Could not create a secure channel'. So I'm using the following line of code

ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;

But also after adding the line, it throws the same error.

But when I compile the same code from the console application it produces the result. Is there any problem with my code or with my mobile device?

Refer the link for this issue. https://docs.microsoft.com/en-us/xamarin/android/app-fundamentals/http-stack?tabs=macos

Windows: Project Options > Android Options, then click the Advanced Options button. Mac: Project Options > Build > Android Build settings and click on the General tab.

This is not my answer. Somebody told me in the comment section. Refer that

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM