Open tobiasisenberg opened 6 years ago
This also happens to non-grafana URLs, such as those pointing to html files in config/static/*.html
Another note: i tried on various devices (phones and tablets) and various Android versions (up to Oreo 8.1).
Another update: this behavior still happens if the URL in the Webview item does not require a special port:
Webview url="https://my.own.domain/grafana/d-solo/000000001/openhab-data?orgId=1&panelId=16&from=now-24h&to=now" height=15
Webview url="https://my.own.domain/static/test.html" height=10
Webview url="https://my.own.domain/static/image.png" height=10
, regardless whether the URL with which the app accesses the OpenHAB instance (as specified in the settings) still uses the port (64443 in this case) or not; the app still does not show the Webview contents.
So maybe the issue is the fact that both the URL for accessing OpenHAB (as specified in the settings) and the URL in the Webview item use the same domain "my.own.domain"? Tested now with the most recent version 2.2.18-beta. The non-beta version from the Play Store shows the Webview items just fine, with or without the special port in the URLs, and with or without the special port in the URL to access the OpenHAB instance (as specified in the settings). Updated the title of the issue to reflect this information.
If the webview content is on the same server than openHAB, you can use remove "https://my.own.domain" from the url.
Interestingly, while this suggested approach of removing "https://my.own.domain" works using BasicUI in a web browser, it works neither in the stable nor in the beta Android app---the space for the webview is being created by both apps but the linked page never loads/is never embedded. Moreover, I don't see why the full URL should fail, after all it works in the stable app and I would expect all correct full URLs to work.
My hunch is that the access with the full URL fails in the beta app because the access to my "https://my.own.domain/" is, of course, password-protected and the beta app has changed something for how the password is stored/reused for accessing one's own server. Yet even a full URL with basic authentication does not seem to work correctly, then it shows only in the stable app but not in the beta app and also not in the web browser.
I thus consider this behavior a bug in the current beta app. There seems to have been a discussion about a related issue and a PR that addressed it, but I am not sure if it is exactly the same issue as in the current beta app since these discussions are from 2015.
I tried to reproduce your issue:
Webview url="http://openhab.local/" height=10
Webview url="http://openhab.local/basicui/app?sitemap=demo2" height=10
Port 80 is protected with basic authentiacation and I can see both webviews. Sometimes they are in the wrong order, but only for a short time. This seems to be a problem with recycled, but uncleared, view (as we had with icons).
Is my.own.domain the same server where openHAB runs? Please note, that browsers may cache credentials and send them to the server without notifying you.
Well, it seems that you are only accessing the OpenHAB instance from within your local network as "openhab.local" would not resolve to your external IP address from outside. I specifically want to link to "https://my.own.domain/..." because I want to be able to access my data both from within my home network and when I am not at home. I can only say that I can access any of these full URLs independently with a web browser (and authentication) from both inside and outside my home network, but when I place the same (full) URLs into a Webview tag (both with port 80 and with a special port) then the access only works for Basic UI in a web browser and in the stable app, but no longer with the beta app. I think that if the approach of using Webviews without "https://my.own.domain" for accessing local content would work not only in the web browser but in the apps as well then it would be fine (should be mentioned in the documentation, though).
I would be more than willing to help testing and debugging this issue with you using my installation to get the bug resolved, if you have specific things for me to try out (starting from coming Wednesday), in that case please contact me by e-mail.
And, btw, I do not think that simply clearing Webviews before they are re-used will address my issue. I tried several times before to force-stop the Android apps and then clearing the cache before restarting them (which should similarly delete previous Webview contents), yet the issue that my local Webview contents was not loaded did not go away. Yet, if your change becomes part of the beta Android app I can test again.
Are you using a valid certificate for your domain?
And, btw, I do not think that simply clearing Webviews before they are re-used will address my issue.
From your posts I can see that there are two issues:
I sometimes get the content of another Webview item previously looked at from the same sitemap, as if that is still in the cache
My PR should fix issue 2. I can attach a debug apk for you tomorrow.
I use a self-signed certificate which I typically accept the first time I use the Android app to access my own OpenHAB server. But you are absolutely right that your fix should address issue #2, but my issue #1 is (a lot) more important for me and I am a bit afraid that if you close this issue post then issue #1 will not be addressed. ;-) But maybe I misread the automatically generated status post of Github here which stated that your fix will close this issue ...
If you send me the APK I can test it on Wednesday.
And to reply to another question I had previously overlooked: yes, my.own.domain runs both OpenHAB and the web sites, both using the same ports and the same authentication. In the apps I enter https://my.own.domain:64443/ as the remote server URL and the login and PW that I would also use to access the web sites and the web-based basic UI.
Do you see Failed to validate the certificate chain, error: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
in the app log?
Sorry for the delay, I was on a plane and then could not think straight due to jet lag. Now I slept and did the test with the beta app. And yes, I do see this error message:
08-22 18:37:23.265 17570 21360 I X509Util: Failed to validate the certificate chain, error: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
Does this mean that with my self-signed certificate I am out of luck?
Does this mean that with my self-signed certificate I am out of luck?
Yes, at least for now. I have to see how we can change the default certificate validation from the webview. For now you can use relativ paths in your webview.
In that case I would like to point out again that there is a third bug here: relative path Webview widgets are shown in neither stable nor beta app (tested with most recent 2.2.19-beta), in neither local nor remote access. I only see the Webview contents when I pull up the Basic UI in a regular Webbrowser (there everything works as expected). Tested code:
Webview url="/static/image.png" height=10
Webview url="/grafana/d-solo/000000001/openhab-data?orgId=1&panelId=16&from=now-24h&to=now" height=15
Again, I'd be happy to help testing/debugging this issue so that it can be sorted out so that we can get it to work for both the browser and the app. Let me know if I need to look for, for example, specific debug messages.
I'm sorry, my suggestion was wrong. For the webview itself there is no difference between absolute and relative urls. The relative urls are transformed to absolute urls before giving them to the webview. Webviews over http and https with official certificates with relative urls are fixed in https://github.com/openhab/openhab-android/commit/b596894d2c653b51638a49941ac6c08dba3c3437 (not yet in the stable release).
I have the same problem as @tobiasisenberg: WebView is not displayed in OpenHAB Android app if it points to a https-URL on my OpenHAB Server using a self-singed certificate. (I cannot setup Let's Encrypt, since the webserver is on purpose not reacheable from the outside. Although this is my internal Network I still want to rely on encrypted connections.) Currently my workaround was to configure the reverse proxy such that only the webview URL is being served also with HTTP - while everything else is only served via HTTPS. But actually, this workaround is really not nice... HTTPS-WebView-URLs to external Websites with "real" certificates are working as well as non-encrypted HTTP-WebView-URLs to my internal server. I tried importing the server certificate at my Android tablet via different ways, but nothing helped.
The rest seems to be working with my OpenHAB Server using a self-signed certificate - it's only the WebView that makes problems...
My server is running with an nginx as reverse-proxy and self-signed ssl-certificate. When using that https-URL, the Sitemap is shown except from the webview pointing to the same server if it is also using that self-signed certificate based https base url. If I change over to unencrypted http, the webview works. However, the webview with https is working in a regular browser (on pc as well as android tablet) and also in the openHAB iPhone app. I imported the certificate in various ways - and in my android tablet’s browser it is now displayed as being trusted. But in the android app it is just not working. ——— EDIT: Sorry, I just noticed that I have written a similar comment already before...
Note that when I try wirh a webview pointing to some external URL with a regular singed ceritificate (e.g. https://google.com/) it is working.
Search the world's information, including webpages, images, videos and more. Google has many special features to help you find exactly what you're looking for.
I imported the certificate in various ways - and in my android tablet’s browser it is now displayed as being trusted. But in the android app it is just not working.
Should be fixed in mobile-foss-beta-debug.zip (Code: https://github.com/mueller-ma/openhab.android/tree/network-security)
@kleintody Did you find time to test my apk?
@mueller-ma Hello, I had the same problem with the HabPanel Beta View (AnchorWebView). I added your changes from the branch to my own (cause of own gcm instance). It works great. Thanks
Thanks for testing. I'll make a PR to get this change in the official app. By the way you can use the official app with your own openhab cloud installation, see https://github.com/openhab/openhab-android/pull/288
@maniac103 I haven't found a solution for this so far. Do you think we should add a hint to webview widgets? https://github.com/mueller-ma/openhab.android/commit/12d804042a7be410fc325f4156c4fcb36cdc3a1a
@mueller-ma This is an interesting idea ... certainly better than not showing any indication IMHO. But the comments above make it sound like you have found a solution? So what's missing now?
Something like https://stackoverflow.com/questions/36553190/check-in-the-onreceivedsslerror-method-of-a-webviewclient-if-a-certificate-is but using the MTM keystore to validate against?
That should work for webviews to the openHAB server, but not to a third party webserver like a webcam. A valid solution though.
I updated #1191: Now webviews accept the certificate if it has been trusted via MTM.
hi guys i have this problem but only on my dad's phone, that is an old lg g2 with android 4.4.2
old lg g2 with android 4.4.2
There's already a PR for bumping the minimum supported version to Android 5: https://github.com/openhab/openhab-android/pull/1719
Actual behaviour
When trying to view Webview items with the beta app, I no longer can see Webview elements on my own server using a special port of the format:
Webview url="https://my.own.domain:64443/grafana/d-solo/000000001/openhab-data?orgId=1&panelId=16&from=now-24h&to=now" height=15
I am not sure if the reason is the own domain or the special port. The same sitemap loads fine in the basicui website (both accessed locally and remotely) and the stable Android app (both accessed locally and remotely). In the beta app I sometimes get the content of another Webview item previously looked at from the same sitemap, as if that is still in the cache. Other Webview elements (not on my own domain and without a special port) also work fine, even in the beta app.Expected behaviour
The web content should be loaded in the app.
Steps to reproduce
Can you reproduce the issue in demo mode?
n/a
Environment data
Client
Server
openHAB Cloud
Logs
App log
openHAB Server log
Reverse Proxy log