Xamarin C# 错误 : SecureChannelFailure (The authentication or decryption has failed.)

标签 xamarin webclient

我用这个:

        WebClient mClient = new WebClient();
        mClient.UseDefaultCredentials = false;
        mClient.Credentials = new NetworkCredential("Name", "Password");
        Uri mUrl = new System.Uri("https://server");
        mClient.DownloadDataAsync(mUrl);
        mClient.DownloadDataCompleted += MClient_DownloadDataCompleted;`

我得到了标题中的错误。

我不明白的是,如果我在 Visual Studio 的控制台应用程序中使用相同的代码,我会得到预期的结果!但是,如果我在我的 android 应用程序中使用此代码,我会在标题中收到错误消息。我在模拟器和设备上试过。

最佳答案

使用 ModernHttpClient 对我不起作用。有效的是更改 Android 项目中的一些设置。首先右键单击项目并选择属性。

Android 选项 > 高级 > HttpClient 实现 = Android

Android 选项 > 高级 > SSL/TLS 实现 = Native TLS 1.2+

我在 Visual Studio 2017 上。

关于Xamarin C# 错误 : SecureChannelFailure (The authentication or decryption has failed.),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42706055/

相关文章:

c# - Xamarin Forms 主细节隐藏后退按钮

xamarin - Droid Library 认为它是可穿戴的 如何让它不可穿戴?

c# - DownloadFileAsync 与 DownloadFileTaskAsync

android - 没有在 Webview 中获得 onReceivedClientCertRequest 的回调

java - 带有请求 header 的 Web 客户端

ios - Xamarin.iOS-无法安装软件包'System.Net.Http 4.0.0',该软件包不包含任何程序集引用

ios - 如何将ios应用程序转换为Xamarin.ios应用程序?

ios - UIAlertController 上的 UITapGestureRecognizer 未触发

c# - WebClient DownloadString UTF-8 不显示国际字符

wcf - 如何将用户凭据从 WebClient 传递到 WCF REST 服务?