/** * Returns the certificate chain associated with the given alias. * * @param alias the alias name * @return the certificate chain (ordered with the user's certificate first and the root * certificate authority last), or null if the given alias does not exist or does not contain * a certificate chain (i.e., the given alias identifies either a <i>trusted certificate * entry</i> or a <i>key entry</i> without a certificate chain). */ public Certificate[] engineGetCertificateChain(String alias) { AbstractMap.SimpleEntry<String, Collection<KeyStore>> pair = getKeystoresForReading(alias); Certificate[] chain = null; try { String entryAlias = pair.getKey(); for (KeyStore keystore : pair.getValue()) { chain = keystore.getCertificateChain(entryAlias); if (chain != null) { break; } } } catch (KeyStoreException e) { throw new IllegalStateException(e); } return chain; }