Android webview访问HTTPS web page如何忽略验证

WebView myWebView = (WebView) findViewById(R.id.webview);

myWebView.loadUrl("https://cap.cityu.edu.hk/studentlan/");

//添加下面2行代码来忽略SSL验证

WebViewClient  mWebviewclient =newWebViewClient(){

publicvoidonReceivedSslError(WebView view, SslErrorHandler handler, SslError error){

handler.proceed();

}

};

myWebView.setWebViewClient(mWebviewclient);


proguard:mapping.txt

xx.xx.xxx

xx.xx.xxxthis$0 -> a

void onReceivedSslError(android.webkit.WebView,android.webkit.SslErrorHandler,android.net.http.SslError) -> onReceivedSslError

所以还要必要在混淆文件proguard.cfg中,加入以下:

-keep public class android.net.http.SslError

-dontwarn android.webkit.WebView

-dontwarn android.net.http.SslError

-dontwarnAndroid.webkit.WebViewClient

你可能感兴趣的:(Android webview访问HTTPS web page如何忽略验证)