【发布时间】:2017-11-02 06:54:15
【问题描述】:
我开发了应用并发布了 google play 商店,然后收到了来自 Google 的通知
主机名验证器 您的应用正在使用 HostnameVerifier 接口的不安全实现。您可以在这篇 Google 帮助中心文章中找到有关如何解决问题的更多信息,包括修复漏洞的截止日期。
我不能使用 HostnameVerifier 或调用 setDefaultHostnameVerifier(),我认为它依赖于一些 3rd 方库。使用了第三方库-Google map, baidu map, firebase crash analytics, firebase phone authentication, quick blox, mob authentication。
我尝试在 splash 中使用这些代码来解决这个问题-
HostnameVerifier hostnameVerifier = org.apache.http.conn.ssl.SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER;
DefaultHttpClient client = new DefaultHttpClient();
SchemeRegistry registry = new SchemeRegistry();
SSLSocketFactory socketFactory = SSLSocketFactory.getSocketFactory();
socketFactory.setHostnameVerifier((X509HostnameVerifier) hostnameVerifier);
registry.register(new Scheme("https", socketFactory, 443));
SingleClientConnManager mgr = new SingleClientConnManager(client.getParams(), registry);
DefaultHttpClient httpClient = new DefaultHttpClient(mgr, client.getParams());
HttpsURLConnection.setDefaultHostnameVerifier(hostnameVerifier);
还有
HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() {
public boolean verify(final String hostname, final SSLSession session) {
if (session.isValid()) {
return true;
}
else
{
return false;
}`
但是,我的应用被 Google Play 商店拒绝了。
请帮我找出这段代码有什么问题?以及如何解决?
【问题讨论】:
标签: android hostname android-security