AND_YOU_with_ME
AND_YOU_with_ME
2017-03-22 01:23

Android开发中https请求验证,如何在自定义的X509TrustManager类中,使用白名单对证书做验证

2
  • java
  • string
  • android
  • class

public class MyX509TrustManager implements X509TrustManager {

        private X509TrustManager tm;  

        public MyX509TrustManager(X509TrustManager tm) {  
            this.tm = tm;  
        }  

        public X509Certificate[] getAcceptedIssuers() {  
            throw new UnsupportedOperationException();  
        }  

        public void checkClientTrusted(X509Certificate[] chain, String authType)  
                throws CertificateException {  
            throw new UnsupportedOperationException();  
        }  

        public void checkServerTrusted(X509Certificate[] chain, String authType)  
                throws CertificateException {  
                                //TODO:使用白名单对证书做验证

        }  


    }
  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

1条回答