在Google Play商店中上传应用程序时,为什么会收到SslErrorHandler?

时间:2019-03-28 06:12:42

标签: java android google-play android-security sslerrorhandler

我已将发行版APK上传到Google Playstore,但由于SslErrorHandler,它始终被拒绝。

        @Override
        public void onReceivedSslError(WebView view, final SslErrorHandler handler, SslError error) {
            final AlertDialog.Builder builder = new AlertDialog.Builder(Registration.this);
            String message = "SSL Certificate error.";

            message += " Do you want to continue anyway?";

            builder.setTitle("SSL Certificate Error");
            builder.setMessage(message);
            builder.setPositiveButton("continue", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    handler.proceed();
                }
            });
            builder.setNegativeButton("cancel", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    handler.cancel();
                }
            });
            final AlertDialog dialog = builder.create();
            dialog.show();
        }

1 个答案:

答案 0 :(得分:1)

一种解决方法是将handler.proceed()和handler.cancel()放入

@Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
    if (error.toString().equals("SSLError")) {
        handler.cancel();
    } else {
        handler.proceed();
    }
}

祝你好运!