如何为 "Visual studio emulator for android" 的模拟器安装证书?

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

我正在开发 Xamarin Form,需要调用 httpclient 来使用公司的内部 https REST api。

不幸的是,它 return 有这个错误

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

我该如何解决这个问题?

要绕过认证验证,您可以:

在Android构建选项中选择

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

在MainActivity.cs中添加这个

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

在 Httpclient init 中改变这个

var httpClient = new HttpClient();

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