Android Question Webview ssl problem

molder26

Member
Licensed User
Longtime User
Hello guys, i am having problems with a url with ssl certificate, i try with Ctrl + B, HU2_ACCEPTALL and only get a white screen.
Thank you in advance!
Regards
 

JohnC

Expert
Licensed User
Longtime User
Is the certificate a self-signed one?
 
Upvote 0

JohnC

Expert
Licensed User
Longtime User
You already added the chromeclient to webview as in my tip #1 in my below signature, right?
 
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
you title the thread "webview..." technically, HU2_ACCEPTALL has nothing to do with webview. and "white screen" has nothing to do with what HU2_ACCEPTALL is supposed to address. how did you go about getting to the white screen?
 
Upvote 0

JohnC

Expert
Licensed User
Longtime User
I saw chromeclient is with webviewextras right?
Yes, this link shows you how to do it:
 
Last edited:
Upvote 0

molder26

Member
Licensed User
Longtime User
JohnC i did it:

B4X:
wve.addWebChromeClient(WebView1, "WVE")
WebView1.LoadUrl("https://www.google.com")

With google.com work, but with my https://url.com doesnt work. In android chrome work well the url.
Thank you in advance
 
Upvote 0

JohnC

Expert
Licensed User
Longtime User
If your app works with https://google.com but not with your wordpress URL, then try viewing a different wordpress website in your app.

If another wordpress website works, then I would look into the theme of your wordpress site to see how it handles mobile visitors.
 
Upvote 0

molder26

Member
Licensed User
Longtime User
i saw this error in logs:
ResponseError. Reason: javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found., Response:
 
Upvote 0

JohnC

Expert
Licensed User
Longtime User
Oh, a certificate problem could definitely cause the white screen.

Try this:

1. Try going into your device and go into the "Security" settings, then view the list of "Trusted credentials".
2. Look for an entry that says "AddTrust" - there may be multiple entries.
3. Try disabling the one that says "AddTrust External CA Root"
4. Reboot your device and see if it will work now.
 
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
there is a way to get webview to ignore ssl issues, but HU2_ACCEPTALL is not actually it. you use HU2_ACCEPTALL with httputils2.
you download the url with httpjob.download (after setting hclient HU2_ACCEPTALL). that should get you the html. check the download first (hint: log it).
assuming you actually get something, load that into the webview.

to use the webview directly, you need to consume the onReceivedSslError event. if you know how to do that, fine. otherwise, try what's in the first paragraph. if job.download gets you nothing, then the problem may be elsewhere. show us the httpjob code and explain exactly what you did to set HU2_ACCEPTALL. we'll go from there.
 
Upvote 0

molder26

Member
Licensed User
Longtime User
there is a way to get webview to ignore ssl issues, but HU2_ACCEPTALL is not actually it. you use HU2_ACCEPTALL with httputils2.
you download the url with httpjob.download (after setting hclient HU2_ACCEPTALL). that should get you the html. check the download first (hint: log it).
assuming you actually get something, load that into the webview.

to use the webview directly, you need to consume the onReceivedSslError event. if you know how to do that, fine. otherwise, try what's in the first paragraph. if job.download gets you nothing, then the problem may be elsewhere. show us the httpjob code and explain exactly what you did to set HU2_ACCEPTALL. we'll go from there.

I try with onReceivedSslError but i only can find WebViewExtras 1.42 in the forum and onReceivedSslError need WebViewExtras2.
 
Upvote 0

JohnC

Expert
Licensed User
Longtime User
WebviewExtras2 has a method to ignore SSL errors, but I have not worked with it before.

I wanted to see if disabling that credential works first because it's a known problem that started on 5/30/20, then explore the webviewextras2 method.
 
Last edited:
Upvote 0

cenyu

Active Member
Licensed User
Longtime User
This is my working code...
You have to download lib from http://b4a.martinpearman.co.uk/webviewextras/

Then:
B4X:
Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.

    Private WebView1 As WebView
    Private we As WebViewExtras
 
 
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("Layout1")
 
    we.Initialize(WebView1)
    Dim client As DefaultWebViewClient
    client.Initialize("client")
    we.SetWebViewClient(client)
    WebView1.LoadUrl("https://192.168.0.200/")
 

End Sub

Sub client_ReceivedSslError(SslErrorHandler1 As SslErrorHandler, SslError1 As SslError)
    Log(SslError1)
    SslErrorHandler1.Proceed
End Sub

The Sub client_ReceivedSslError is very important! Without this sub nothings work!

Good luck :)
 
Last edited:
Upvote 0
Top