DEN
DEN

Reputation: 1893

How can I install certificate for "Visual studio emulator for android"'s emulator?

I am working on a Xamarin Form that need to call httpclient to consume company's internal https REST api.

Unfortunately, it return with this error

Javax.Net.Ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.

How can i resolve this?

Upvotes: 2

Views: 1438

Answers (1)

Bruno Caceiro
Bruno Caceiro

Reputation: 7189

To bypass certification validation you can:

In Android Build options choose

HttpClient Implementation: AndroidClientHandler
SSL/TLS implementation: Default (Native TLS 1.2+)

In MainActivity.cs add this

ServicePointManager.ServerCertificateValidationCallback += (o, cert, chain, errors) => true;

In the Httpclient init change this

var httpClient = new HttpClient();

To

var httpClient = new HttpClient(new System.Net.Http.HttpClientHandler());

Upvotes: 1

Related Questions