How to fix unsafe implementation of X509TrustManager in Android app

后端 未结 5 1882
被撕碎了的回忆
被撕碎了的回忆 2020-12-04 13:31

Google has advised that I have an unsafe implementation of the interface X509TrustManager in my Android application and need to change my code as follows:

5条回答
  •  一向
    一向 (楼主)
    2020-12-04 14:02

    I have meet this problem.If your code is like that:

     TrustManager tm = new X509TrustManager()  {
        public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {
        }
    
        public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {
        }
    
        public X509Certificate[] getAcceptedIssuers() {
            return null;
        }
    };
    

    it will accept all certificate and it is a bad idea,so google send you mail. We can make a change to accept self-signed certificate too. I solved it,here is my question and my solution

提交回复
热议问题