From b2e81e6bc19bec418f29086d1f5eb865a851c90d Mon Sep 17 00:00:00 2001 From: maiha Date: Fri, 16 Sep 2016 23:30:36 +0900 Subject: [PATCH] Disable ssl when `-D without_openssl` is given --- src/kemal.cr | 2 ++ src/kemal/cli.cr | 2 ++ src/kemal/config.cr | 4 ++++ 3 files changed, 8 insertions(+) diff --git a/src/kemal.cr b/src/kemal.cr index 6946313..65954ca 100644 --- a/src/kemal.cr +++ b/src/kemal.cr @@ -12,7 +12,9 @@ module Kemal config.add_handler Kemal::RouteHandler::INSTANCE config.server = HTTP::Server.new(config.host_binding, config.port, config.handlers) + {% if ! flag?(:without_openssl) %} config.server.tls = config.ssl + {% end %} Kemal::Sessions.run_reaper! diff --git a/src/kemal/cli.cr b/src/kemal/cli.cr index 3d7ae0b..0f7f772 100644 --- a/src/kemal/cli.cr +++ b/src/kemal/cli.cr @@ -39,6 +39,7 @@ module Kemal end def configure_ssl + {% if ! flag?(:without_openssl) %} if @ssl_enabled puts "SSL Key Not Found"; exit unless @key_file puts "SSL Certificate Not Found"; exit unless @cert_file @@ -47,6 +48,7 @@ module Kemal ssl.set_cert_file @cert_file.not_nil! Kemal.config.ssl = ssl.context end + {% end %} end def read_env diff --git a/src/kemal/config.cr b/src/kemal/config.cr index 93d6165..bb9145e 100644 --- a/src/kemal/config.cr +++ b/src/kemal/config.cr @@ -8,7 +8,11 @@ module Kemal INSTANCE = Config.new HANDLERS = [] of HTTP::Handler ERROR_HANDLERS = {} of Int32 => HTTP::Server::Context -> String + {% if flag?(:without_openssl) %} + @ssl : Bool? + {% else %} @ssl : OpenSSL::SSL::Context::Server? + {% end %} property host_binding, ssl, port, env, public_folder, logging, always_rescue, serve_static, server, extra_options