Does the Web View on Android support SSL?

前端 未结 4 1090
挽巷
挽巷 2020-11-27 05:43

The WebView control on android, does it support SSL?

I am trying to load a web page that uses a trusted ssl certificate but the WebView is

4条回答
  •  臣服心动
    2020-11-27 06:09

    Not an expert, just what i could find on the web. from what I understand, the WebView does indeed support ssl, however, the blank screen is an indication that the WebView does not believe that the certificate is valid. This may happen with a certificate that is self-signed or a from a root auth that is not set up in android (perfectly valid cert does not validate). In any case, if you are using froyo or better you can try something like:

    import android.webkit.WebView;
    import android.webkit.WebViewClient;
    import android.webkit.SslErrorHandler;
    import android.net.http.SslError;
    
    ...
    
    engine = (WebView) findViewById(R.id.my_webview);
    engine.setWebViewClient(new WebViewClient() {
    
        @Override
        public void onReceivedSslError (WebView view, SslErrorHandler handler, SslError error) {
            handler.proceed();
        }
    });
    

提交回复
热议问题