Google Play警告:WebViewClient.onReceivedSslError处理程序

Viv*_*tal 11 ssl android-security

我最近收到了Google发来的一封电子邮件,内容如下:"Google Play警告:SSL错误处理程序漏洞".在这封电子邮件中,Google解释说我的应用程序有一个["不安全的WebViewClient实现.onReceivedSslError处理程序.具体来说,该实现会忽略所有SSL证书验证错误,使您的应用程序容易受到中间人攻击.攻击者可以更改受影响的WebView内容,读取传输的数据(如登录凭据),并使用JavaScript在应用程序内执行代码."] ....................

我在我的代码中使用:

    webView.setWebViewClient(new WebViewClient() {

        @Override
        public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {}

        @Override
        public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
            handler.proceed();
        }

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            return super.shouldOverrideUrlLoading(view, url);
        }

        @Override
        public void onPageFinished(WebView view, String url) {
            super.onPageFinished(view, url);
            // My code
        }
    });
Run Code Online (Sandbox Code Playgroud)

//我的代码

webview_ClientPost(webView, "https://secure.payu.in/_payment", mapParams.entrySet());
Run Code Online (Sandbox Code Playgroud)

为什么Google会发送有关SSL的警告?这是我的代码问题还是PayUMoney问题?

Ant*_*ony 2

问题出在你的代码中。handler.proceed();当你这样打电话时,它会有效地消除你连接中的所有安全性。

你应该删除你的onReceivedSslError方法。默认实现将拒绝不安全的连接。