android - 谷歌播放警告 : How to fix incorrect implementation of HostnameVerifier?

标签 android https warnings android-security

我收到来自 Google 的通知说: 安全警报

您的应用使用了不安全的 HostnameVerifier 实现。请参阅这篇 Google 帮助中心文章了解详细信息,包括修复漏洞的截止日期。

是否有人收到此警报?如果收到,您是如何解决的?

我的 HostnameVeriefier 类如下:

public class NullHostNameVerifier implements HostnameVerifier {
    public boolean verify(String hostname, SSLSession session) {
        Log.i("UtilImpl", "Approving certificate for " + hostname);
        return true;
    }
}

请帮我找出这段代码有什么问题?以及如何解决?

最佳答案

如果您知道它不会损害您用户的数据隐私并且只想绕过此检查,请尝试类似的方法

public class NullHostNameVerifier implements HostnameVerifier {
    public boolean verify(String hostname, SSLSession session) {
        return Build.VERSION.SDK_INT >= Build.VERSION_CODES.BASE_1_1;
    }
}

思路是让verify明显不返回true,这样自动检查就检测不到

关于android - 谷歌播放警告 : How to fix incorrect implementation of HostnameVerifier?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41312795/

相关文章:

使用 RapidSSL 证书时 Node.js HTTPS 服务器没有响应

Facebook 应用程序 - 静默 "Protocols must match"错误

android - 无法在 xamarin android 中创建 wcf 服务对象/客户端以供引用

android - 尝试测试 AnimatedVectorDrawable 时出错, "Can' t 从 x 到 z 变形”

java - 将 JPG 图像作为位图上传到 Android Studio 时图像分辨率是否丢失?

php - 无法执行 PDO 查询(无效参数号)但不无效

php - 引用 - 这个错误在 PHP 中意味着什么?

android - 如何使用 actions.xml 集成应用程序操作?

python - 通过 Python 和请求调用 URL 时 SSL 超时

python - Python 指令中的预期类型 'Union[ndarray, Iterable]' 警告