use of org.apache.drill.exec.ssl.SSLConfig in project drill by apache.
the class TestSSLConfig method testInvalidHadoopKeystore.
@Test
public void testInvalidHadoopKeystore() throws Exception {
Configuration hadoopConfig = new Configuration();
String hadoopSSLFileProp = MessageFormat.format(HADOOP_SSL_CONF_TPL_KEY, SSLConfig.Mode.SERVER.toString().toLowerCase());
hadoopConfig.set(hadoopSSLFileProp, "ssl-server-invalid.xml");
ConfigBuilder config = new ConfigBuilder();
config.put(ExecConstants.USER_SSL_ENABLED, true);
config.put(ExecConstants.SSL_USE_HADOOP_CONF, true);
SSLConfig sslv;
try {
sslv = new SSLConfigBuilder().config(config.build()).mode(SSLConfig.Mode.SERVER).initializeSSLContext(false).validateKeyStore(true).hadoopConfig(hadoopConfig).build();
fail();
} catch (Exception e) {
assertTrue(e instanceof DrillException);
}
}
use of org.apache.drill.exec.ssl.SSLConfig in project drill by apache.
the class TestSSLConfig method testForTrustStore.
@Test
public void testForTrustStore() throws Exception {
ConfigBuilder config = new ConfigBuilder();
config.put(ExecConstants.HTTP_TRUSTSTORE_PATH, "/root");
config.put(ExecConstants.HTTP_TRUSTSTORE_PASSWORD, "root");
config.put(ExecConstants.SSL_USE_HADOOP_CONF, false);
SSLConfig sslv = new SSLConfigBuilder().config(config.build()).mode(SSLConfig.Mode.SERVER).initializeSSLContext(false).validateKeyStore(true).build();
assertEquals(true, sslv.hasTrustStorePath());
assertEquals(true, sslv.hasTrustStorePassword());
assertEquals("/root", sslv.getTrustStorePath());
assertEquals("root", sslv.getTrustStorePassword());
}
use of org.apache.drill.exec.ssl.SSLConfig in project drill by apache.
the class TestSSLConfig method testMissingKeystorePassword.
@Test
public void testMissingKeystorePassword() throws Exception {
ConfigBuilder config = new ConfigBuilder();
config.put(ExecConstants.HTTP_KEYSTORE_PATH, "/root");
config.put(ExecConstants.HTTP_KEYSTORE_PASSWORD, "");
config.put(ExecConstants.SSL_USE_HADOOP_CONF, false);
config.put(ExecConstants.USER_SSL_ENABLED, true);
try {
SSLConfig sslv = new SSLConfigBuilder().config(config.build()).mode(SSLConfig.Mode.SERVER).initializeSSLContext(false).validateKeyStore(true).build();
fail();
// Expected
} catch (Exception e) {
assertTrue(e instanceof DrillException);
}
}
use of org.apache.drill.exec.ssl.SSLConfig in project drill by apache.
the class SslContextFactoryConfigurator method configureNewSslContextFactory.
/**
* Tries to apply ssl options configured by user. If provided configuration isn't valid,
* new self-signed certificate will be generated and used in sslContextFactory.
*
* @return new configured sslContextFactory
* @throws Exception when generation of self-signed certificate failed
*/
public SslContextFactory configureNewSslContextFactory() throws Exception {
SSLConfig sslConf = new SSLConfigBuilder().config(config).mode(SSLConfig.Mode.SERVER).initializeSSLContext(false).validateKeyStore(true).build();
final SslContextFactory sslContextFactory = new SslContextFactory();
if (sslConf.isSslValid()) {
useOptionsConfiguredByUser(sslContextFactory, sslConf);
} else {
useAutoGeneratedSelfSignedCertificate(sslContextFactory);
}
return sslContextFactory;
}
Aggregations