DBMNG数据库管理与应用

独立思考能力,对于从事科学研究或其他任何工作,都是十分必要的。
当前位置:首页 > 移动应用 > Android

Android webview访问HTTPS自签名证书网站

使用webview访问自签名证书网站(ssl加密的url)时,页面显示是空白或提示错误,而使用系统自带的浏览器打开时,会弹出确认证书的对话框。
这里采用忽略证书验证的方法(但有安全风险,慎用之):
WebView myWebView = (WebView) findViewById(R.id.webview);  
myWebView.loadUrl("https://www.xxxexample.com/");   
//添加以下行代码来忽略SSL验证  
WebViewClient  mWebviewclient = new WebViewClient(){  
     public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error){          
          //handler.cancel(); // Android默认的处理方式
	  handler.proceed();  // 接受所有网站的证书
	  //handleMessage(Message msg); // 进行其他处理
     }
};  
myWebView.setWebViewClient(mWebviewclient);  
本站文章内容,部分来自于互联网,若侵犯了您的权益,请致邮件chuanghui423#sohu.com(请将#换为@)联系,我们会尽快核实后删除。
Copyright © 2006-2023 DBMNG.COM All Rights Reserved. Powered by DEVSOARTECH            豫ICP备11002312号-2

豫公网安备 41010502002439号