@Test void getTruststoreAsByteArray() throws Exception { underTest.createKeystoreAndTruststore(keystorePath, "localhost"); final KeyStore keystore = KeyStore.getInstance("jks"); final byte[] bytes = underTest.getTrustStoreAsByteArray(); keystore.load(new ByteArrayInputStream(bytes), new char[0]); final Certificate certificate = keystore.getCertificate("jzonbie"); assertThat(new X509CertImpl(certificate.getEncoded()).getSubjectDN().getName()).isEqualTo("CN=localhost"); }
public byte[] getTrustStoreAsByteArray() { final KeyStore trustStore = getTrustStore(); try(final ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) { trustStore.store(outputStream, new char[0]); return outputStream.toByteArray(); } catch (Exception e) { throw new RuntimeException("Failed to convert truststore to byte array", e); } }
HttpsSupport { public byte[] getTrustStoreAsByteArray() { final KeyStore trustStore = getTrustStore(); try(final ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) { trustStore.store(outputStream, new char[0]); return outputStream.toByteArray(); } catch (Exception e) { throw new RuntimeException("Failed to convert truststore to byte array", e); } } }
HttpsSupport { public byte[] getTrustStoreAsByteArray() { final KeyStore trustStore = getTrustStore(); try(final ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) { trustStore.store(outputStream, new char[0]); return outputStream.toByteArray(); } catch (Exception e) { throw new RuntimeException("Failed to convert truststore to byte array", e); } }  }
HttpsSupport { public byte[] getTrustStoreAsByteArray() { final KeyStore trustStore = getTrustStore(); try(final ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) { trustStore.store(outputStream, new char[0]); return outputStream.toByteArray(); } catch (Exception e) { throw new RuntimeException("Failed to convert truststore to byte array", e); } }  void createKeystoreAndTruststore(String keystorePath, String subject); KeyStore getTrustStore(); byte[] getTrustStoreAsByteArray(); }
HttpsSupport { public byte[] getTrustStoreAsByteArray() { final KeyStore trustStore = getTrustStore(); try(final ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) { trustStore.store(outputStream, new char[0]); return outputStream.toByteArray(); } catch (Exception e) { throw new RuntimeException("Failed to convert truststore to byte array", e); } }  void createKeystoreAndTruststore(String keystorePath, String subject); KeyStore getTrustStore(); byte[] getTrustStoreAsByteArray();  }