由于漏洞问题,Android应用拒绝了google play

时间:2016-06-16 19:31:53

标签: android ssl

将应用程序上传到游戏市场后获取此笔记: "要正确处理SSL证书验证,请在自定义X509TrustManager接口的checkServerTrusted方法中更改代码,以便在服务器提供的证书不符合您的期望时引发CertificateException或IllegalArgumentException。"怎么可能这样做,请帮忙。

我的代码是:enter image description here

2 个答案:

答案 0 :(得分:0)

使用切换到简单模式 然后刷新页面并再次尝试上传APK。 In google play developer console

答案 1 :(得分:0)

I also had SSLCertification issue at the time uploading singed apk.
you have to return true for all your trusted http hosts including 3rd party libraries http.
  

我在这里说的是我如何解决这个问题,对不起安全我没有提出原始的链接路径,这些Link帮助我

        TrustManager[] trustAllCerts = new TrustManager[]{new X509TrustManager() {
            public X509Certificate[] getAcceptedIssuers() {
                X509Certificate[] myTrustedAnchors = new X509Certificate[0];
                return myTrustedAnchors;
            }

            @Override
            public void checkClientTrusted(X509Certificate[] certs, String authType) {
            }

            @Override
            public void checkServerTrusted(X509Certificate[] certs, String authType) {
            }
        }};


    SSLContext sc = SSLContext.getInstance("SSL");
    sc.init(null, trustAllCerts, new SecureRandom());
    HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
    HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() {
        @Override
        public boolean verify(String hostname, SSLSession arg1) {
            if (hostname.equalsIgnoreCase("demo.mysite.com") ||
                    hostname.equalsIgnoreCase("prod.mysite.com") ||
                    hostname.equalsIgnoreCase("22.2.202.22:3333") ||
                    hostname.equalsIgnoreCase("cloud.cloudDeveSite.net") ||                            
                    hostname.equalsIgnoreCase("11.2.222.22:2222") ||
                    hostname.equalsIgnoreCase("multispidr.3rdPartyLibrary.io")) {
                return true;
            } else {
                return false;
            }
        }
    });
  

提及所有出现SSLCertification问题的api,你也必须提到第三方api,当你运行该代码时,你会得到错误的HTTP链接。