简体   繁体   English

如何在Xamarin Android应用程序C#中启用TLS 1.2支持

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

I'm developing a Xamarin project. 我正在开发Xamarin项目。 With the help of C# code, I need to access the azure API for my project. 在C#代码的帮助下,我需要访问项目的Azure API。 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 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. Windows:“项目选项”>“ Android选项”,然后单击“高级选项”按钮。 Mac: Project Options > Build > Android Build settings and click on the General tab. Mac:项目选项>构建> Android构建设置,然后单击常规标签。

This is not my answer. 这不是我的答案。 Somebody told me in the comment section. 有人在评论部分告诉我。 Refer that 提到那个

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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