title: Need help in understanding getAcceptedIssuers method
body: <p>I am writing a code to get all the trusted certificates from android device.</p>
  
  <p>Here's my code,</p>
  
  <pre><code>public class MyX509TrustManager implements X509TrustManager {
  X509TrustManager pkixTrustManager;
  
  public MyX509TrustManager(KeyStore keystore)
          throws Exception {
  
      TrustManagerFactory tmf = TrustManagerFactory.getInstance("X509");
      tmf.init(keystore);
  
      TrustManager tms[] = tmf.getTrustManagers();
  
      for (int i = 0; i &lt; tms.length; i++) {
          if (tms[i] instanceof X509TrustManager) {
              pkixTrustManager = (X509TrustManager) tms[i];
  
              System.out.println("The class is " + pkixTrustManager.getClass());
              return;
          }
      }
  
      throw new Exception("Couldn't initialize");
  }
  
  public void checkClientTrusted(X509Certificate[] arg0, String arg1)
          throws CertificateException {
  
      try {
          pkixTrustManager.checkClientTrusted(arg0, arg1);
      } catch (CertificateException excep) {
  
      }
  
  }
  
  public void checkServerTrusted(X509Certificate[] arg0, String arg1)
          throws CertificateException {
      // TODO Auto-generated method stub
      try {
          pkixTrustManager.checkServerTrusted(arg0, arg1);
      } catch (CertificateException excep) {
  
      }
  }
  
  public X509Certificate[] getAcceptedIssuers() {
  
  
      System.out.println("Control inside the issuers method");
  
      System.out.println( "Number of trusted certificates is "+   pkixTrustManager.getAcceptedIssuers().length);
      return pkixTrustManager.getAcceptedIssuers();
  
  }
  }
  </code></pre>
  
  <p>When I call getAcceptedIssuers method I am getting the empty array(Confirmed by the array length returned by getacceptedIssuers methos)</p>
  
  <p>What I am doing wrong here.</p>
  
  <p>Can any one help me on this please to get the list of trusted certificates from android device.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I am calling the constructor of MyX509TrustManager in another class:</p>
  
  <pre><code>KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
  // KeyStore.getDefaultType() returns "BKS"
  
  MyX509TrustManager mm = new MyX509TrustManager(ks);
  
  X509Certificate [] trucerts = m.getAcceptedIssuers();
  </code></pre>
  
  <p>How can I load the keystore with trusted certificates?</p>