简体   繁体   English

如何为“Visual Studio emulator for android”的模拟器安装证书?

[英]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. 我正在开发一个Xamarin表单 ,需要调用httpclient来使用公司的内部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? 我该如何解决这个问题?

To bypass certification validation you can: 要绕过认证验证,您可以:

In Android Build options choose 在Android Build选项中选择

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

In MainActivity.cs add this 在MainActivity.cs中添加此项

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

In the Httpclient init change this 在Httpclient init中更改此内容

var httpClient = new HttpClient();

To

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM