@Test
public void testTrustStoreWithMultipleEntries() throws KeyStoreException, CertificateException, NoSuchAlgorithmException, IOException {

    File caPem = getTempFile("ca/cert-multi.pem");
    KeyStore keystore = createKeyStore();
    KeyStoreUtil.updateWithCaPem(keystore, caPem);
    List<String> aliases = asList(keystore.aliases());
    assertEquals(aliases.size(), 2);
    Map<String, String> expectedAliases = new HashMap<String, String>();
    expectedAliases.put("ca.test.jolokia.org",CA_CERT_SUBJECT_DN_CN);
    expectedAliases.put("another.test.jolokia.org","CN=another.test.jolokia.org");
    for (String alias : aliases) {
        String key = findMatchingKeyAsSubstring(expectedAliases, alias);
        assertNotNull(key);
        String expectedSubjectDN = expectedAliases.remove(key);
        assertNotNull(expectedSubjectDN);
        X509Certificate cert = (X509Certificate) keystore.getCertificate(alias);
        assertTrue(cert.getSubjectDN().getName().contains(expectedSubjectDN));
        RSAPublicKey certPublicKey = (RSAPublicKey) cert.getPublicKey();
        assertEquals(certPublicKey.getAlgorithm(),"RSA");
    }
    assertEquals(expectedAliases.size(),0);
}