Confused about handling SSL Errors in WebView

2,253 views
Skip to first unread message

whitemice

unread,
Feb 16, 2009, 7:36:18 AM2/16/09
to android-platform
[Note: I am reposting this issue over on android-platform, because I
am still confused as to how WebView was built after the SSL Error
classes were removed]

I have a WebView and I want to capture an error, most likely related
to a web page having an invalid SSL certificate (company Intranet).
rrently the MyWebViewClient.onPageStarted() method is called, and no
secure content is shown on the page.

Generally I would expect WebViewClient.onReceivedError() to be called
to handle this situation, although the documentation is not quite
clear on exactly what kind of errors this method covers.

Looking at the Android Browser implementation source code, it seems to
call WebViewClient.onReceivedSslError() on line 2954, which triggers
the relevant site certificate prompt:
http://android.git.kernel.org/?p=platform/packages/apps/Browser.git;a=blob;f=src/com/android/browser/BrowserActivity.java

...which is method that was removed in 0.9:
http://code.google.com/android/migrating/m5-0.9/changes/android.webkit.WebViewClient.html

I am not clued up enough to take on the WebKit source and can't find
any documentation on what if anything has replaced the
onReceivedSslError() method.
Is this a bug/omission in the Android platform? How was the
"release-1.0" browser complied with missing classes? Am I doing
something wrong?
Thanks in advance for your feedback.
Mark

Fred Grott

unread,
Feb 16, 2009, 7:40:40 AM2/16/09
to android-...@googlegroups.com
I believe you are looking for a different method check in WebChromeClient and WebClient it shoudl have onssl in the method name..

My best guess WebClient

whitemice

unread,
Feb 16, 2009, 9:25:29 AM2/16/09
to android-platform
Thanks for the feedback.
Unfortunately nether WebChromeClient or WebViewClient have a onSsl***
() method name, at least according to the current documentation:
http://developer.android.com/reference/android/webkit/WebViewClient.html
http://developer.android.com/reference/android/webkit/WebChromeClient.html

The only thing Google Search was able to turn up was a
WebViewClient.onReceivedSslError() which has since been removed:
http://code.google.com/android/migrating/m5-0.9/changes/android.webkit.WebViewClient.html

If there is no equivalent method, or the WebViewClient.onReceivedError
() mistakenly fails to receive this event, then this would be a bug.

It still doesn’t example how apparently removed classes like
“android.net.http.SslError” made it into the 1.0 build.
http://android.git.kernel.org/?p=platform/packages/apps/Browser.git;a=blob;f=src/com/android/browser/BrowserActivity.java

Regards
Mark

Manuel

unread,
Feb 25, 2009, 6:41:21 AM2/25/09
to android-platform
I'm facing the same problems, being unable even to detect when the SSL
cert is not being approved. Any ideas on how to face this?

On the other hand, the browser app does indeed detect this and allows
to override it. There should be a way of dealing with this.

Thanks!

On Feb 16, 3:25 pm, whitemice <markbr...@zedray.co.uk> wrote:
> Thanks for the feedback.
> Unfortunately nether WebChromeClient or WebViewClient have a onSsl***
> () method name, at least according to the current documentation:http://developer.android.com/reference/android/webkit/WebViewClient.htmlhttp://developer.android.com/reference/android/webkit/WebChromeClient...
>
> The only thing Google Search was able to turn up was a
> WebViewClient.onReceivedSslError() which has since been removed:http://code.google.com/android/migrating/m5-0.9/changes/android.webki...
>
> If there is no equivalent method, or the WebViewClient.onReceivedError
> () mistakenly fails to receive this event, then this would be a bug.
>
> It still doesn’t example how apparently removed classes like
> “android.net.http.SslError” made it into the 1.0 build.http://android.git.kernel.org/?p=platform/packages/apps/Browser.git;a...
>
> Regards
> Mark

Fred Grott

unread,
Feb 25, 2009, 6:44:28 AM2/25/09
to android-...@googlegroups.com
Which sdk are you targeting as your objections refr to sdk 0.9 which does not apply sdk 1.0

The methods I pointed to are sdk 1.0 and sdk 1.1..

whitemice

unread,
Feb 26, 2009, 3:55:56 AM2/26/09
to android-platform
Hi Fred
I am targeting 1.0 as Google are yet to release an update for my ADP1.

Here is the current WebChromeClient and WebViewClient specification:
http://developer.android.com/reference/android/webkit/WebChromeClient.html
http://developer.android.com/reference/android/webkit/WebViewClient.html

Neither seem to have the „onssl“ method that you referred to in your
original response. I only referred to the m5-0.9 change document
because it describes the removal of the “onReceivedSslError” method,
and because the same method somehow appears in the current browsers
source code.

Are you able to shed some light on this mystery?
Regards
Mark

Fred Grott

unread,
Feb 26, 2009, 4:02:12 AM2/26/09
to android-...@googlegroups.com
It is not labeled as onsssl until later trunks..its named differently in the links you posted.

whitemice

unread,
Mar 2, 2009, 4:59:51 AM3/2/09
to android-platform
Hi Fred
You have managed to make 3x cryptic answers in a row, which is
somewhat ironic considering the thread title. ;-)

#1>>I believe you are looking for a different method check in
WebChromeClient and WebClient it shoudl have onssl in the method
name.. <<
#2>>The methods I pointed to are sdk 1.0 and sdk 1.1.. <<
#3>>It is not labeled as onsssl until later trunks..its named
differently in the links you posted. <<

In order to save this thread, can someone who knows the solution
please post some sample code or point to the relevant method in the
documentation.
Thanks for the help
Mark

Reply all
Reply to author
Forward
0 new messages