Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I use this:

        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;`

and i get the error in the headline.

What i do not understand is that if i use the same code in a console application in Visual Studio, i get the expected result! But if i use this code in my android app i get the error in the headline. i tried it on the emulator and with a device.

like image 444
spam-michael Avatar asked Nov 29 '22 06:11

spam-michael


1 Answers

Using ModernHttpClient didn't work for me. What did work was changing some settings in the Android project. Start by right clicking on the project and selecting Properties.

Android Options > Advanced > HttpClient implementation = Android

Android Options > Advanced > SSL/TLS implementation = Native TLS 1.2+

I'm on Visual Studio 2017.

like image 102
nthpixel Avatar answered Dec 04 '22 21:12

nthpixel