The browser on your PC will eject the Certificate error dialog box, prompting you to continue browsing without ignoring the error. You can actually do this in webview to implement a page that has problems loading the certificate.
Copy Code code as follows:
WebView WebView = (webview) Findviewbyid (R.id.webview);
Webview.setwebviewclient (New Webviewclient () {
@Override
public void Onreceivedsslerror (WebView view, Sslerrorhandler handler, sslerror error) {
NEVER do this!!! ***
Super.onreceivedsslerror (view, handler, error);
Let ' s ignore SSL error
Handler.proceed ();
}
}
Simply overload the Webviewclient onreceivedsslerror () function like this and execute handler.proceed () in it, ignoring the SSL certificate error and continuing loading the page.
Note here that you should never call Super.onreceivedsslerror (). This is because Webviewclient's Onreceivedsslerror () function contains a handler.cancel () (see source, which means stop loading, so if you call Super.onreceivedsslerror (), The result is that the first access cannot be loaded, the second can be loaded (not knowing why), and a libc segment error may occur:
Copy Code code as follows:
A/libc:fatal Signal (SIGSEGV) at 0x00000010 (code=1)