title: Java code to display expiration date of certificates in a Java KeyStore
body: <p>Looking for java code to display expiration date of certificates in a given keystore.</p>
  
  <p>What i am expecting is below output after running the java code:</p>
  
  <p>CerticateName: 
  CertificateExpirationDate: 
  NumberOfDaysLeft:</p>
  
  <h1>Update</h1>
  
  <p>I have come up with the code below, Which print certificate alias, I am interested in Expriation date</p>
  
  <pre><code>import java.io.FileInputStream;
  import java.security.KeyStore;
  import java.util.Enumeration;
  
  public class sslcertslist {
    public static void main(String[] argv) throws Exception {
      FileInputStream is = new FileInputStream("MyKeystore.jks");
      KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType());
      String password = "MyPassword";
      keystore.load(is, password.toCharArray());
  
      Enumeration e = keystore.aliases();
      for (; e.hasMoreElements();) {
        String alias = (String) e.nextElement();
  
        boolean b = keystore.isKeyEntry(alias);
  
        b = keystore.isCertificateEntry(alias);
        System.out.println(alias);
      }
      is.close();
    }
  }
  </code></pre>