@Test public void testTrustStore() throws GeneralSecurityException, IOException { CommonsDataLoader dataLoader = new CommonsDataLoader(); dataLoader.setSslTruststorePath(CORRECT_KS_PATH); dataLoader.setSslTruststoreType(KS_TYPE); dataLoader.setSslTruststorePassword("azert"); byte[] binaries = dataLoader.get(URL); assertNotNull(binaries); assertTrue(binaries.length > 0); }
/** * @param dataLoader data loader * @param configuration configuration */ public static void decorateWithSslSettings(CommonsDataLoader dataLoader, Configuration configuration) { if (configuration.isSslConfigurationEnabled()) { logger.debug("Configuring SSL"); dataLoader.setSslKeystorePath(configuration.getSslKeystorePath()); dataLoader.setSslTruststorePath(configuration.getSslTruststorePath()); if (configuration.getSslKeystoreType() != null) { dataLoader.setSslKeystoreType(configuration.getSslKeystoreType()); } if (configuration.getSslKeystorePassword() != null) { dataLoader.setSslKeystorePassword(configuration.getSslKeystorePassword()); } if (configuration.getSslTruststoreType() != null) { dataLoader.setSslTruststoreType(configuration.getSslTruststoreType()); } if (configuration.getSslTruststorePassword() != null) { dataLoader.setSslTruststorePassword(configuration.getSslTruststorePassword()); } } } }
@Test(expected = DSSException.class) // TODO check root cause SSLHandshakeException public void testWrongTrustStore() throws GeneralSecurityException, IOException { CommonsDataLoader dataLoader = new CommonsDataLoader(); dataLoader.setSslTruststorePath(WRONG_KS_PATH); dataLoader.setSslTruststoreType(KS_TYPE); dataLoader.setSslTruststorePassword("azert"); dataLoader.setSslKeystorePath(WRONG_KS_PATH); dataLoader.setSslKeystoreType(KS_TYPE); dataLoader.setSslKeystorePassword("azert"); byte[] binaries = dataLoader.get(URL); assertNotNull(binaries); assertTrue(binaries.length > 0); }