@Before public void storeSystemProperties() { systemProperties = new Properties(); storeSystemProperty(CertUtils.TRUST_STORE_SYSTEM_PROPERTY); storeSystemProperty(CertUtils.TRUST_STORE_PASSWORD_SYSTEM_PROPERTY); storeSystemProperty(CertUtils.KEY_STORE_SYSTEM_PROPERTY); storeSystemProperty(CertUtils.KEY_STORE_PASSWORD_SYSTEM_PROPERTY); }
@Test public void testLoadTrustStoreFromFileUsingSystemProperties() throws CertificateException, NoSuchAlgorithmException, KeyStoreException, IOException { System.setProperty(CertUtils.TRUST_STORE_SYSTEM_PROPERTY, FABRIC8_STORE_PATH); System.setProperty(CertUtils.TRUST_STORE_PASSWORD_SYSTEM_PROPERTY, String.valueOf(FABRIC8_STORE_PASSPHRASE)); KeyStore trustStore = CertUtils.createTrustStore(getMultipleCertsInputSteam(), null, null); assertEquals(3, trustStore.size()); verifyFabric8InStore(trustStore); }
@Test public void testLoadKeyStoreFromFileUsingSystemProperties() throws InvalidKeySpecException, CertificateException, NoSuchAlgorithmException, KeyStoreException, IOException, URISyntaxException { System.setProperty(CertUtils.KEY_STORE_SYSTEM_PROPERTY, FABRIC8_STORE_PATH); System.setProperty(CertUtils.KEY_STORE_PASSWORD_SYSTEM_PROPERTY, String.valueOf(FABRIC8_STORE_PASSPHRASE)); String privateKeyPath = Utils.filePath(getClass().getResource("/ssl/fabric8")); String multipleCertsPath = Utils.filePath(getClass().getResource("/ssl/multiple-certs.pem")); KeyStore trustStore = CertUtils.createKeyStore(null, multipleCertsPath, null, privateKeyPath, "RSA", "changeit", null, null); assertEquals(2, trustStore.size()); verifyFabric8InStore(trustStore); }
@Test public void testLoadingMultipleCertsFromSameFile() throws CertificateException, NoSuchAlgorithmException, KeyStoreException, IOException { KeyStore ts = CertUtils.createTrustStore(getMultipleCertsInputSteam(), null, "changeit".toCharArray()); assertTrue(ts.size() >= 2); }
@Test public void testLoadKeyStoreFromFileUsingConfigProperties() throws InvalidKeySpecException, CertificateException, NoSuchAlgorithmException, KeyStoreException, IOException { InputStream privateKey = getClass().getResourceAsStream("/ssl/fabric8"); KeyStore trustStore = CertUtils.createKeyStore(getMultipleCertsInputSteam(), privateKey, "RSA", "changeit".toCharArray(), FABRIC8_STORE_PATH, FABRIC8_STORE_PASSPHRASE); assertEquals(2, trustStore.size()); verifyFabric8InStore(trustStore); }
@Test public void testLoadTrustStoreFromFileUsingConfigProperties() throws CertificateException, NoSuchAlgorithmException, KeyStoreException, IOException { KeyStore trustStore = CertUtils.createTrustStore(getMultipleCertsInputSteam(), FABRIC8_STORE_PATH, FABRIC8_STORE_PASSPHRASE); assertEquals(3, trustStore.size()); verifyFabric8InStore(trustStore); }