@Test
public void testAMKeystoreGenerated() throws Exception {

  File keystoreFile = new File(secDir, SliderKeys.KEYSTORE_FILE_NAME);
  Assert.assertTrue("Keystore does not exist: " + keystoreFile,
                    keystoreFile.exists());
  InputStream is = null;
  try {
    is = new FileInputStream(keystoreFile);
    KeyStore keystore = KeyStore.getInstance("pkcs12");
    String password = SecurityUtils.getKeystorePass();
    keystore.load(is, password.toCharArray());
    Certificate certificate = keystore.getCertificate(
        keystore.aliases().nextElement());
    Assert.assertNotNull(certificate);
    if (certificate instanceof X509Certificate) {
      X509Certificate x509cert = (X509Certificate) certificate;
      // Get subject
      Principal principal = x509cert.getSubjectDN();
      String subjectDn = principal.getName();
      Assert.assertEquals("wrong DN",
                          "CN=cahost",
                          subjectDn);
      // Get issuer
      principal = x509cert.getIssuerDN();
      String issuerDn = principal.getName();
      Assert.assertEquals("wrong Issuer DN",
                          "CN=cahost",
                          issuerDn);
    }
  } finally {
    if(null != is) {
      is.close();
    }
  }
}