1

In my android app I need to go to a url which in turn redirects to the 3d secure page of respective banks and after whatever action user does the url is redirected with few parameters in the url viz status, id and error(Eg. https://theurl?st=2&id=70288&err=1) which are required in the app to perform further actions. This implementation works perfectly fine using a webview for android 4.4 and above. I get an error message “Could not establish a secure connection” on phones lower than Android 4.3. After looking up about the issue i understand this is a known problem for android 4.3 and less because of the SSL and TSL configuration on the server (TLS/SSLv3 in webview android). The server configurations can not be changed and thus I am finding a way to make this work for Android 4.3 and below. Please could anyone guide on any alternate way to get around this issue?

Community
  • 1
  • 1
  • Have you tried adding the server certificate manually to the `TrustManager`? See: https://developer.android.com/training/articles/security-ssl.html for more info. – Darwind May 27 '16 at 09:01
  • Haven't tried this, but will give it a try. Could you please point me to a sample implementation if you have any? Thank you. – The Android way May 27 '16 at 12:29
  • It's right there in the link. You put your public `.cer` file inside the `asset` folder and then read it in to memory. Then you add it to the current `TrustManager`. If it's still unclear I'll add an answer on how to do it. – Darwind May 28 '16 at 09:54

1 Answers1

0

Override the onReceivedSslError method in your webViewClient. In that method include what you want to do further.

class CustomWebView extends WebViewClient {

public void onReceivedSslError(WebView view, android.webkit.SslErrorHandler handler, android.net.http.SslError error) {
            handler.cancel();
            //your code here
        }
}
Akanksha Hegde
  • 1,738
  • 11
  • 14
  • Have tried doing that, but it does not go in the onReceivedSslError() in goes to onRecieveError() with a message -"Couldn't establish a secure connection." – The Android way May 27 '16 at 12:27