lib/piedesaint.rb in piedesaint-0.1.1 vs lib/piedesaint.rb in piedesaint-0.1.2

- old
+ new

@@ -73,11 +73,13 @@ def self.app ( options = {} ) ::Rack::Builder.app do use ::Rack::CommonLogger use ::Rack::ShowExceptions - use ::Rack::SslEnforcer, http_port: options[:http_port], https_port: options[:https_port] + if ( !options[:key].nil? and !options[:key].empty? ) + use ::Rack::SslEnforcer, http_port: options[:http_port], https_port: options[:https_port] + end use ::Rack::Deflater if options[:username].nil? or options[:username].empty? puts "Service without Basic Authentication" else @@ -116,16 +118,18 @@ #ctx = ::Puma::MiniSSL::SSLContext.new #ctx.key = "./server.key" #ctx.cert = "./server.crt" #ctx.verify_mode = ::Puma::MiniSSL::VERIFY_NONE - ctx = ::OpenSSL::SSL::SSLContext.new - ctx.key = OpenSSL::PKey::RSA.new File.read(options[:key]) - ctx.cert = OpenSSL::X509::Certificate.new File.read(options[:cert]) - ctx.verify_mode = ::OpenSSL::SSL::VERIFY_NONE - puma.add_tcp_listener options[:host], options[:http_port] - puma.add_ssl_listener options[:host], options[:https_port], ctx + + if ( !options[:key].nil? and !options[:key].empty? ) + ctx = ::OpenSSL::SSL::SSLContext.new + ctx.key = OpenSSL::PKey::RSA.new File.read(options[:key]) + ctx.cert = OpenSSL::X509::Certificate.new File.read(options[:cert]) + ctx.verify_mode = ::OpenSSL::SSL::VERIFY_NONE + puma.add_ssl_listener options[:host], options[:https_port], ctx + end puma.min_threads = 1 puma.max_threads = 10 begin