How to fix unsafe implementation of X509TrustManager in Android app

后端 未结 5 1887
被撕碎了的回忆
被撕碎了的回忆 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:14

    I have solved this using the following code:

    public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {
                    try {
                        chain[0].checkValidity();
                    } catch (Exception e) {
                        throw new CertificateException("Certificate not valid or trusted.");
                    }
                }
    

提交回复
热议问题