Xamarin 表单 - Android - 握手仅在 HTTPS 中失败

时间:2021-03-30 21:57:31

标签: asp.net-mvc xamarin.forms xamarin.android

我有一个运行我的网站的 Aspnet Mvc5 项目,我想使用带有 webView 的 xamarin.forms 制作一个应用程序,我可以通过网站 https://mywebsite.com 访问我的网站,但是当我尝试在本地访问时,我得到了一个白页和控制台日志中的错误

<块引用>

[chromium] [ERROR:ssl_client_socket_impl.cc(924)] 握手失败; 返回 -1,SSL 错误代码 1,net_error -202

我知道是因为在本地我的 ssl 是不安全的,经过数小时的搜索,我的问题的解决方案似乎是“绕过” ssl 错误,我发现了该代码:

public override void OnReceivedSslError(WebView view, SslErrorHandler handler, SslError error)
    {
        handler.Proceed(); //pass directly.        

    }

但是我不知道在哪里使用它。我的项目实际上是一个空的 Xamarin 表单项目,我只是对 MainPage.xaml

进行了更改
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="TestAppMobile01.MainPage">

        <WebView Source="https://192.168.1.X:44302"></WebView>

</ContentPage>

如果我添加代码 android:usesCleartextTraffic="true"

,我可以通过 http 访问我的网站

AndroidManifest.xml 中,但在 https 中我得到了错误。

问题实际上出在 Android 上。

0 个答案:

没有答案