0

I have been working on Xamarin for Android and I have a problem accessing localhost from WebView. Yes, I know that on emulators and devices one can not access localhost so I installed Conveyor by Keyoti which gives me access to my localhost through MYIP:PORT. Localhost is setup to redirect to CAS server login that my application needs as initial login. The main problem is that webview is not showing anything but if I try to access for e.g google.com it will show main page of google. Also, I am using Navigated and Navigating properties and I always get to Navigated property which outputs Loaded.. on the screen. Furthermore, if I try to access this "https://myip:45456" through google chrome on my device or through new incognito window it works like a charm but refuses to work inside of a webview.

Here is some xaml code that I tried because there is not much going on in the code-behind:

<WebView VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand"
                 Navigated="WebView_Navigated" Navigating="WebView_Navigating"
                 Source = "myip:45456">
        </WebView>

I'm really not getting what the problem is, so if anybody has experience in this area, help would be much appreciated.

EDIT:

After losing my head around this I've found out the problem lays in certificates and I'm getting this output message: Failed to validate the certificate chain, error: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.

I have tried couple of other solutions such as: Xamarin Android issue connecting via HTTPS to site with self-signed certificate: "Trust anchor for certification path not found."

and workaround with ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true in MainActivity but it's still showing the same error. Maybe it is something in configuration, but I can't find what it is?! :(

Kude14
  • 1
  • 1
  • Are you using `https:` in the source/uri string? (i.e. what you have shown in your xaml will not work) – SushiHangover Dec 21 '19 at 19:46
  • @SushiHangover I'm sorry, yes I am using `https:` in my xaml but i accidentally deleted it when writing the question. – Kude14 Dec 21 '19 at 20:44

0 Answers0