小编Dad*_* Mj的帖子

Xamarin:java.security.cert.CertPathValidatorException:未找到证书路径的信任锚

在 Xamarin 中。我一直在尝试在我的 Web API 和我的 Xamarin 项目之间进行通信。这是我的控制器的代码:

//  GET api/values
    public List<string> Get()
    {
        List<string> values = new List<string>();
        values.Add("Value 1");
        values.Add("Value 2");
        return values;
    }
Run Code Online (Sandbox Code Playgroud)

这是我在MainPage.xaml.cs 中的GET 请求

    public async void BindToListView()
    {
        HttpClient client = new HttpClient();
        var response = await client.GetStringAsync("https://10.0.2.2:#####/api/Values");
        var posts = JsonConvert.DeserializeObject<List<Posts>>(response);
        lv.ItemsSource = posts;
    }
Run Code Online (Sandbox Code Playgroud)

每当我尝试运行我的 Android 应用程序和我的 Web API 应用程序时。我不断收到此异常:

    Javax.Net.Ssl.SSLHandshakeException: 
'java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.'
Run Code Online (Sandbox Code Playgroud)

我试过将它粘贴到我的MainActivity.cs 中,但它仍然不起作用。

ServicePointManager.ServerCertificateValidationCallback += (o, cert, chain, errors) …
Run Code Online (Sandbox Code Playgroud)

c# ado.net android xamarin

2
推荐指数
1
解决办法
3948
查看次数

标签 统计

ado.net ×1

android ×1

c# ×1

xamarin ×1