### Question:
KafkaClientKeystores { public KeyStore createTruststore(KeystoreConfig conf) throws IOException, CertificateException, KeyStoreException, NoSuchAlgorithmException { InputStream is = conf.issuingCa().orElse(conf.caChain()); List<X509Certificate> chain = readCertificateChain(certFactory, is); return createTruststore(chain.get(0)); } KafkaClientKeystores(String password); KeyStore createKeystore(KeystoreConfig conf); KeyStore createKeystore(InputStream privateKey, InputStream certificate,
                                 InputStream caChain); KeyStore createTruststore(KeystoreConfig conf); KeyStore createTruststore(X509Certificate certificate); static List<X509Certificate> readCertificateChain(CertificateFactory factory, InputStream is); byte[] writeStore(Optional<String> directory, String type, KeyStore store); static void main(String[] argv);  }### Answer:
@Test public void testTruststoreFromConfig() throws Exception { KafkaClientKeystores keystores = new KafkaClientKeystores(PASSWORD); KeyStore store = keystores.createTruststore(new ResourceStreamConfig()); assertCertificateSubjectName(store.getCertificate("caroot"), ISSUER_CN); }
@Test public void testTruststoreFromConfigWithEmptyIssuingCa() throws Exception { KafkaClientKeystores keystores = new KafkaClientKeystores(PASSWORD); KeyStore store = keystores.createTruststore(new ResourceStreamConfig(){ @Override public Optional<InputStream> issuingCa() { return empty(); } }); assertCertificateSubjectName(store.getCertificate("caroot"), ISSUER_CN); }