同样在这里 - 不安全的主机名验证检测在APK
您的应用使用不安全的实现的HostnameVerifier的。有关详细信息,请参阅此Google帮助中心文章,其中包括 修复漏洞的截止日期,请参阅 。我没有使用HostnameVerifier 而不是调用setDefaultHostnameVerifier。此外 - 我使用OKHTTP lib用于http请求。我希望定义TrustManager将解决 这个问题。
由于我不是继承HostnameVerifier
或致电setDefaultHostnameVerifier()
我认为它依赖于一些第三方库。既然不能检测这样的lib我想我会尝试添加一类具有下面的代码
HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() {
public boolean verify(final String hostname, final SSLSession session) {
if (check if SSL is really valid)
return true;
else
return false;
}
});
到我的项目,并会看它是否修复该问题。
所以我做到了,另外每webView的我已经添加了重写的方法
@Override
public void onReceivedSslError(WebView view, final SslErrorHandler handler, SslError error) {
// the main thing is to show dialog informing user
// that SSL cert is invalid and prompt him to continue without
// protection: handler.proceed();
// or cancel: handler.cancel();
String message;
switch(error.getPrimaryError()) {
case SslError.SSL_DATE_INVALID:
message = ResHelper.getString(R.string.ssl_cert_error_date_invalid);
break;
case SslError.SSL_EXPIRED:
message = ResHelper.getString(R.string.ssl_cert_error_expired);
break;
case SslError.SSL_IDMISMATCH:
message = ResHelper.getString(R.string.ssl_cert_error_idmismatch);
break;
case SslError.SSL_INVALID:
message = ResHelper.getString(R.string.ssl_cert_error_invalid);
break;
case SslError.SSL_NOTYETVALID:
message = ResHelper.getString(R.string.ssl_cert_error_not_yet_valid);
break;
case SslError.SSL_UNTRUSTED:
message = ResHelper.getString(R.string.ssl_cert_error_untrusted);
break;
default:
message = ResHelper.getString(R.string.ssl_cert_error_cert_invalid);
}
mSSLConnectionDialog = new MaterialDialog.Builder(getParentActivity())
.title(R.string.ssl_cert_error_title)
.content(message)
.positiveText(R.string.continue_button)
.negativeText(R.string.cancel_button)
.titleColorRes(R.color.black)
.positiveColorRes(R.color.main_red)
.contentColorRes(R.color.comment_grey)
.backgroundColorRes(R.color.sides_menu_gray)
.onPositive(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(MaterialDialog materialDialog, DialogAction dialogAction) {
mSSLConnectionDialog.dismiss();
handler.proceed();
}
})
.onNegative(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(MaterialDialog materialDialog, DialogAction dialogAction) {
handler.cancel();
}
})
.build();
mSSLConnectionDialog.show();
}
到
mWebView.setWebViewClient(new WebViewClient() {
... // other corresponding overridden methods
}
最后谷歌称:
安全扫描完整
无已知的漏洞会在APK 158中检测到。
但是我不确定代码是什么,HostNameVerifier
或onReceivedSslError()
的mWebView.setWebViewClient
。
你使用像Glide第三方库吗?同样的警报在这里,不知道如何解决它。代码中没有HostNameVerifier的直接实现。 – Stan
仅使用Google广告和Google兼容性库。我的一些项目包括Xposed框架JAR,jcifs samba源代码和Apache commons.net源代码。但受影响的项目没有这些。 – 3c71