我正在处理一个 Xamarin表单,该表单需要调用httpclient
来使用公司内部的https REST api。
不幸的是,它返回此错误
Javax.Net.Ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
我该如何解决?
答案 0 :(得分:0)
要绕过认证验证,您可以:
在“ Android构建”选项中选择
HttpClient Implementation: AndroidClientHandler
SSL/TLS implementation: Default (Native TLS 1.2+)
在MainActivity.cs中添加此
ServicePointManager.ServerCertificateValidationCallback += (o, cert, chain, errors) => true;
在Httpclient初始化中更改此
var httpClient = new HttpClient();
收件人
var httpClient = new HttpClient(new System.Net.Http.HttpClientHandler());