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 org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.classification.InterfaceAudience;
import org.apache.hadoop.conf.Configuration;
@ -66,12 +67,12 @@ public class InfoServer {
builder.setLogDir(logDir);
}
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"),
c.get("ssl.server.keystore.password"),
HBaseConfiguration.getPassword(c,"ssl.server.keystore.password", null),
c.get("ssl.server.keystore.type", "jks"))
.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"));
}
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.hadoop.conf.Configuration;
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.SmallTests;
import org.apache.hadoop.hbase.http.ssl.KeyStoreTestUtil;
@ -81,12 +82,13 @@ public class TestSSLHttpServer extends HttpServerFunctionalTest {
.setName("test")
.addEndpoint(new URI("https://localhost"))
.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"),
sslConf.get("ssl.server.keystore.password"),
HBaseConfiguration.getPassword(sslConf, "ssl.server.keystore.password", null),
sslConf.get("ssl.server.keystore.type", "jks"))
.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();
server.addServlet("echo", "/echo", TestHttpServer.EchoServlet.class);
server.start();