HBASE-13848 Use Credential Provider when available for SSL passwords in InfoServer.

This commit is contained in:
Sean Busbey 2015-06-05 10:22:52 -05:00
parent 7595bdfb1a
commit 47a9ff5d1f
2 changed files with 9 additions and 6 deletions

View File

@ -24,6 +24,7 @@ import java.net.URI;
import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServlet;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.classification.InterfaceAudience; import org.apache.hadoop.hbase.classification.InterfaceAudience;
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configuration;
@ -66,12 +67,12 @@ public class InfoServer {
builder.setLogDir(logDir); builder.setLogDir(logDir);
} }
if (httpConfig.isSecure()) { if (httpConfig.isSecure()) {
builder.keyPassword(c.get("ssl.server.keystore.keypassword")) builder.keyPassword(HBaseConfiguration.getPassword(c, "ssl.server.keystore.keypassword", null))
.keyStore(c.get("ssl.server.keystore.location"), .keyStore(c.get("ssl.server.keystore.location"),
c.get("ssl.server.keystore.password"), HBaseConfiguration.getPassword(c,"ssl.server.keystore.password", null),
c.get("ssl.server.keystore.type", "jks")) c.get("ssl.server.keystore.type", "jks"))
.trustStore(c.get("ssl.server.truststore.location"), .trustStore(c.get("ssl.server.truststore.location"),
c.get("ssl.server.truststore.password"), HBaseConfiguration.getPassword(c, "ssl.server.truststore.password", null),
c.get("ssl.server.truststore.type", "jks")); c.get("ssl.server.truststore.type", "jks"));
} }
this.httpServer = builder.build(); this.httpServer = builder.build();

View File

@ -29,6 +29,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileUtil; import org.apache.hadoop.fs.FileUtil;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.testclassification.MiscTests; import org.apache.hadoop.hbase.testclassification.MiscTests;
import org.apache.hadoop.hbase.testclassification.SmallTests; import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.apache.hadoop.hbase.http.ssl.KeyStoreTestUtil; import org.apache.hadoop.hbase.http.ssl.KeyStoreTestUtil;
@ -81,12 +82,13 @@ public class TestSSLHttpServer extends HttpServerFunctionalTest {
.setName("test") .setName("test")
.addEndpoint(new URI("https://localhost")) .addEndpoint(new URI("https://localhost"))
.setConf(conf) .setConf(conf)
.keyPassword(sslConf.get("ssl.server.keystore.keypassword")) .keyPassword(HBaseConfiguration.getPassword(sslConf, "ssl.server.keystore.keypassword",
null))
.keyStore(sslConf.get("ssl.server.keystore.location"), .keyStore(sslConf.get("ssl.server.keystore.location"),
sslConf.get("ssl.server.keystore.password"), HBaseConfiguration.getPassword(sslConf, "ssl.server.keystore.password", null),
sslConf.get("ssl.server.keystore.type", "jks")) sslConf.get("ssl.server.keystore.type", "jks"))
.trustStore(sslConf.get("ssl.server.truststore.location"), .trustStore(sslConf.get("ssl.server.truststore.location"),
sslConf.get("ssl.server.truststore.password"), HBaseConfiguration.getPassword(sslConf, "ssl.server.truststore.password", null),
sslConf.get("ssl.server.truststore.type", "jks")).build(); sslConf.get("ssl.server.truststore.type", "jks")).build();
server.addServlet("echo", "/echo", TestHttpServer.EchoServlet.class); server.addServlet("echo", "/echo", TestHttpServer.EchoServlet.class);
server.start(); server.start();