Skip to content Skip to sidebar Skip to footer

Xamarin Android Error In (https, Ssl, Tls)

I try to create an app in 'Microsoft Visual Studio 2017' Xamarin Android App. If i repelasd with http and not (https) it works fine My qustion is: How can i reguest a https call? B

Solution 1:

Maybe it's still helping OP or someone else stumbling over this question: I wanted to access our company API that is using a certificate issued by a trusted Third Party via an Samsung S7 (Android 8) connected to our Blackberry Server. The device itself had the necessary certificate installed, but I still got the Trust Failure Exception until I switched the HTTPS-Implementation like OP said:

Right click on the Android project -> Settings -> Android-Options -> Advanced

Change the HTTPClient implementation to Android and the SSL/TLS implementation to Native TLS 1.2+

Then I got the following error:

java.security.cert.CertPathValidatorException: Trust anchor for certification pathnot found.

So it seems you need to point Android to its own certificate stores. To do this follow these steps:

Create a subdirectory xml in your Resources directory

Inside, create network_security_config.xml with the following content

<?xml version="1.0" encoding="utf-8" ?><network-security-config><base-config><trust-anchors><!-- Trust preinstalled CAs --><certificatessrc="system" /><!-- Additionally trust user added CAs --><certificatessrc="user" /></trust-anchors></base-config></network-security-config>

Open your AndroidManifest.xml and add the following attribute to the application-Tag

<application [...] android:networkSecurityConfig="@xml/network_security_config">

In my case it got the whole thing working without errors afterwards.

Post a Comment for "Xamarin Android Error In (https, Ssl, Tls)"