title: Not able to import certificate in cacert
body: <p>I have <code>JAVA_HOME=C:\Users\myuser\jdk1.8.0_65</code></p>
  
  <p>JRE Sytem Library in Eclipse points to <code>C:\Users\myuser\jdk1.8.0_65</code></p>
  
  <p><code>java -version</code> gives <code>C:\Users\myuser\jdk1.8.0_65</code></p>
  
  <p>Importing certificate by:</p>
  
  <blockquote>
    <p>C:\Users\myuser\jdk1.8.0_65\bin\keytool.exe -importcert -trustcacerts -keystore C:\Users\myuser\jdk1.8.0_65\jre\lib\security\cacerts -storepass changeit -noprompt -alias ldap -file C:\Users\myuser\certificates\ldap_cer.cer</p>
  </blockquote>
  
  <p>Keytool list gives:</p>
  
  <pre><code>C:\Users\myuser&gt;keytool -list
  Enter keystore password:
  Keystore type: JKS
  Keystore provider: SUN
  
  Your keystore contains 0 entries
  </code></pre>
  
  <p>When I try to check the certificate with below program I can see the entry, why <code>keytool -list</code> doesn't give me the same result? How can I add certificate? What I am missing?</p>
  
  <pre><code>package com.;
  import java.io.File;
  import java.io.FileInputStream;
  import java.io.FileNotFoundException;
  import java.io.IOException;
  import java.security.KeyStore;
  import java.security.KeyStoreException;
  import java.security.NoSuchAlgorithmException;
  import java.security.cert.Certificate;
  import java.util.Enumeration;
  public class HandShake {
  static FileInputStream  is;
  public static void main(String[] args) {
  try {
  
      File file = new File("C://Users//myuser//jdk1.8.0_65//jre//lib//security//cacerts");
      System.setProperty("javax.net.ssl.keyStore", file.getAbsolutePath());
      System.out.println(System.getProperty("javax.net.ssl.keyStore"
              ));
      is= new FileInputStream(file);
      KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType());
      String password = "changeit";
      keystore.load(is, password.toCharArray());
      Enumeration enumeration = keystore.aliases();
      while(enumeration.hasMoreElements()) {
          String alias = (String)enumeration.nextElement();
          if(alias.equals("ldap")){
  
          System.out.println("alias name: " + alias);
          Certificate certificate = keystore.getCertificate(alias);
          System.out.println(certificate.toString());
          }
      }
  
  } catch (java.security.cert.CertificateException e4) {
      e4.printStackTrace();
  } catch (NoSuchAlgorithmException e1) {
      e1.printStackTrace();
  } catch (FileNotFoundException e2) {
      e2.printStackTrace();
  } catch (KeyStoreException e3) {
      e3.printStackTrace();
  } catch (IOException e) {
      e.printStackTrace();
  }finally {
      if(null != is)
          try {
              is.close();
          } catch (IOException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
  }
  }
  }
  </code></pre>