FlinkKeyStoreManager { public Set<X509Certificate> getAllX509Certificates() throws KeyStoreException { HashSet<X509Certificate> result = new HashSet<>(); Enumeration<String> enumAlias = this.keystore.aliases(); while (enumAlias.hasMoreElements()) { Certificate currentCert = this.keystore.getCertificate(enumAlias.nextElement()); if (currentCert instanceof X509Certificate) { LOG.debug(((X509Certificate) currentCert).getSubjectDN().getName()); result.add((X509Certificate)currentCert); } } return result; } FlinkKeyStoreManager(); void openKeyStore(Path path, String keyStoreType, String keyStorePassword); Key getPrivateKey(String alias, String password); Certificate getCertificate(String alias); String getPassword(String alias, String passwordPassword); void setPassword(String alias, String password, String passwordPassword); void store(Path path, String keyStorePassword); Set<X509Certificate> getAllX509Certificates();  }
@Test public void getAllX509Certificates() throws IOException, NoSuchAlgorithmException, CertificateException, KeyStoreException, InvalidAlgorithmParameterException { ClassLoader classLoader = getClass().getClassLoader(); String fileName="cacerts"; String fileNameKeyStore=classLoader.getResource(fileName).getFile(); Path file = new Path(fileNameKeyStore); FlinkKeyStoreManager fksm = new FlinkKeyStoreManager(); fksm.openKeyStore(file, "JKS", "changeit"); Set<X509Certificate> mostTrustedCAList=fksm.getAllX509Certificates(); assertEquals(104,mostTrustedCAList.size(),"Most trusted CA list has length 104"); }