diff --git a/apiv3.properties b/apiv3.properties index 72ca81c..86d132d 100644 --- a/apiv3.properties +++ b/apiv3.properties @@ -6,6 +6,8 @@ mongo.password= redis.address=209.222.96.50 redis.port=6379 http.port=80 +http.keystoreFile=/home/keystore.idk +http.keystorePassword=123abc librato.email=cmcdonald.main@gmail.com librato.apiToken=a818c3eca8a59d6d9cf76dc9f0d237c6aa97f257c482ce3363cf55a5431bc153 librato.sourceIdentifier=apiv3-dev-01 diff --git a/src/main/java/net/frozenorb/apiv3/APIv3.java b/src/main/java/net/frozenorb/apiv3/APIv3.java index ede4b58..7f0d720 100644 --- a/src/main/java/net/frozenorb/apiv3/APIv3.java +++ b/src/main/java/net/frozenorb/apiv3/APIv3.java @@ -28,6 +28,7 @@ import io.vertx.core.http.HttpHeaders; import io.vertx.core.http.HttpMethod; import io.vertx.core.http.HttpServer; import io.vertx.core.http.HttpServerOptions; +import io.vertx.core.net.JksOptions; import io.vertx.ext.web.Router; import io.vertx.ext.web.RoutingContext; import io.vertx.ext.web.handler.BodyHandler; @@ -253,14 +254,20 @@ public final class APIv3 extends AbstractVerticle { } private void setupHttpServer() { - HttpServer webServer = vertx.createHttpServer( - new HttpServerOptions() - //.setSsl(true) - //.setKeyStoreOptions(new JksOptions().setPath("c:\\Users\\cmcdonald\\Desktop\\apiv3.jks").setPassword("password")) - .setCompressionSupported(true) - ); + HttpServerOptions httpServerOptions = new HttpServerOptions(); + httpServerOptions.setCompressionSupported(true); - Router http = Router.router(vertx); + if (!config.getProperty("http.keystoreFile").isEmpty()) { + httpServerOptions.setSsl(true); + httpServerOptions.setKeyStoreOptions( + new JksOptions() + .setPassword(config.getProperty("http.keystorePassword")) + .setPath(config.getProperty("http.keystoreFile")) + ); + } + + HttpServer webServer = vertx.createHttpServer(httpServerOptions); + Router http = Router.router(vertx); // we just name this http to make the route declarations easier to read http.route().handler(LoggerHandler.create(LoggerFormat.TINY)); http.route().handler(TimeoutHandler.create(TimeUnit.SECONDS.toMillis(5)));