Google Play Security Alert - Your app is using an unsafe implementation of the HostnameVerifier

后端 未结 5 1635
庸人自扰
庸人自扰 2020-11-30 12:34

Recently one of my app got a security alert from Google Play as below.

You app is using an unsafe implementation of the HostnameVerifier. And refer a link to Google

5条回答
  •  醉酒成梦
    2020-11-30 13:30

    Please check my code I have only verified domains that my app uses. In your code you must verify all domains your app uses. I have used my server and Fabric.com so my code is below

    HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() {
        @Override
        public boolean verify(String hostname, SSLSession arg1) {
            if (hostname.equalsIgnoreCase("api.my.com") || 
                hostname.equalsIgnoreCase("api.crashlytics.com") || 
                hostname.equalsIgnoreCase("settings.crashlytics.com")) {
                return true;
            } else {
                return false;
            }
        }
    });
    

提交回复
热议问题