diff --git a/src/kemal.cr b/src/kemal.cr index ebc4ff31..e2b7b6eb 100644 --- a/src/kemal.cr +++ b/src/kemal.cr @@ -39,10 +39,6 @@ module Kemal server = config.server ||= HTTP::Server.new(config.handlers) - {% if !flag?(:without_openssl) %} - config.server.not_nil!.tls = config.ssl - {% end %} - config.running = true yield config @@ -51,7 +47,15 @@ module Kemal return unless config.running unless server.each_address { |_| break true } - server.bind_tcp(config.host_binding, config.port) + {% if !flag?(:without_openssl) %} + if server_context = config.ssl + server.bind_ssl(config.host_binding, config.port, server_context) + else + server.bind_tcp(config.host_binding, config.port) + end + {% else %} + server.bind_tcp(config.host_binding, config.port) + {% end %} end display_startup_message(config, server)