In case you want to use the APK outside the Google Play Store, e.g., private a solution like the following will probably work:
@Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
/*...*/
handler.proceed();
}
In case you want to add an additional optional layer of security, you can try to make use of certificate pinning. IMHO this is not necessary for private or internal usage tough.
If you plan to publish the app on the Google Play Store, then you should avoid
@Override onReceivedSslError(...){...}. Especially making use of handler.proceed(). Google will find this code snippet and will reject your app for sure since the solution with handler.proceed() will suppress all kinds of built-in security mechanisms.
And just because of the fact that browsers do not complain about your
https connection, it does not mean that the SSL certificate itself is
trusted at all!
In my case, the SSL certificate chain was broken. You can quickly test such issues with SSL Checker or more intermediate with SSLLabs. But please do not ask me how this can happen. I have absolutely no clue.
Anyway, after reinstalling the SSL certificate, all errors regarding the "untrusted SSL certificate in WebView whatsoever" disappeared finally. I also removed the @Override for onReceivedSslError(...) and got rid of handler.proceed(), and é voila my app was not rejected by Google Play Store (again).