【发布时间】:2021-07-12 05:07:07
【问题描述】:
我上个月发布了一个生产 Android 应用程序,但我在使用 SSL 错误处理程序时遇到了问题。
我遵循了 Stackoverfollow 和 Google 的教程,但是 Google 仍然没有批准我的应用程序(注意:此 QA 不是重复的)。
我的代码实现如下:
任何使用 WebViewClient 的 Fragment 或 Activity,我都控制了这样的 SSL 错误
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
LogI("onReceivedSslError: " + error.getCertificate());
AlertDialog.Builder builder = new AlertDialog.Builder(ctx);
AlertDialog alertDialog = builder.create();
String message;
switch (error.getPrimaryError()) {
case SslError.SSL_UNTRUSTED:
message = "The certificate authority is not trusted.";
break;
case SslError.SSL_EXPIRED:
message = "The certificate has expired.";
break;
case SslError.SSL_IDMISMATCH:
message = "The certificate Hostname mismatch.";
break;
case SslError.SSL_NOTYETVALID:
message = "The certificate is not yet valid.";
break;
case SslError.SSL_DATE_INVALID:
message = "The date of the certificate is invalid.";
break;
default:
message = "A generic error occurred.";
break;
}
message += " Do you want to continue anyway?";
alertDialog.setTitle("SSL Certificate Error");
alertDialog.setMessage(message);
alertDialog.setButton(DialogInterface.BUTTON_POSITIVE, "OK", (dialog, which) -> handler.proceed());
alertDialog.setButton(DialogInterface.BUTTON_NEGATIVE, "Cancel", (dialog, which) -> handler.cancel());
alertDialog.show();
}
那么,为什么我的应用未获批准?接下来我该怎么做?
感谢您的建议!
更新 1: 我在 2019 年发布了我的应用程序并多次更新(没有问题)。但是从 2021/5 开始,我遇到了这个问题。
【问题讨论】:
-
@Eishon 我们的团队也已经阅读并实现了这一点,但您可以看到上面显示的结果
标签: android android-fragments google-play android-security