I have an Ionic 5.x app with the InAppBrowser plugin. I am trying to load a website with the plugin, the browser opens but the page is completely blank and with no errors thrown.
After many hours of debugging I have concluded that the issue is the certificate of the website not being trusted.
What does not make sense is the website is secure when viewed on a browser and is "Verified by: DigiCert Inc"
Other questions with same issue: Loading url in ionic shows blank screen, Cordova inAppBrowser opens www.google.com but not my custom facebook login page?
Does anyone have any ideas on why this is happening?
The code I am using to open:
this.browser = this.inAppBrowser.create( "https://mywebsite.com/", "_blank", "location=yes" );
this.browser.on("loadstart").subscribe( event => {
console.log( event ); // not triggered
});
this.browser.on("loadstop").subscribe( event => {
console.log( event ); // triggered
});
this.browser.on("loaderror").subscribe( event => {
console.log( event ); // not triggered
});
After many many hours of digging around I was finally able to find a solution. Editing a plugin file is not ideal but it does fix this issue!
Edit this file: plugins/cordova-plugin-inappbrowser/src/android/InAppBrowser.java
Add this to the import section:
import android.net.http.SslError;
import android.webkit.SslErrorHandler;
Then add this to the InAppBrowserClient
class ( around line 1224 ):
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
handler.proceed();
return;
}