diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/webrick/https.rb | 17 | ||||
| -rw-r--r-- | lib/webrick/ssl.rb | 12 |
2 files changed, 24 insertions, 5 deletions
diff --git a/lib/webrick/https.rb b/lib/webrick/https.rb index 1494973e74..4826654d3a 100644 --- a/lib/webrick/https.rb +++ b/lib/webrick/https.rb @@ -131,5 +131,22 @@ module WEBrick server = lookup_server(req) server ? server.ssl_context : nil end + + # :stopdoc: + + ## + # Check whether +server+ is also SSL server. + # Also +server+'s SSL context will be created. + + alias orig_virtual_host virtual_host + + def virtual_host(server) + if @config[:SSLEnable] && !server.ssl_context + raise ArgumentError, "virtual host must set SSLEnable to true" + end + orig_virtual_host(server) + end + + # :startdoc: end end diff --git a/lib/webrick/ssl.rb b/lib/webrick/ssl.rb index a30cbc3699..8a334eaff1 100644 --- a/lib/webrick/ssl.rb +++ b/lib/webrick/ssl.rb @@ -147,7 +147,13 @@ module WEBrick # SSL context for the server when run in SSL mode def ssl_context # :nodoc: - @ssl_context ||= nil + @ssl_context ||= begin + if @config[:SSLEnable] + ssl_context = setup_ssl_context(@config) + @logger.info("\n" + @config[:SSLCertificate].to_text) + ssl_context + end + end end undef listen @@ -158,10 +164,6 @@ module WEBrick def listen(address, port) # :nodoc: listeners = Utils::create_listeners(address, port) if @config[:SSLEnable] - unless ssl_context - @ssl_context = setup_ssl_context(@config) - @logger.info("\n" + @config[:SSLCertificate].to_text) - end listeners.collect!{|svr| ssvr = ::OpenSSL::SSL::SSLServer.new(svr, ssl_context) ssvr.start_immediately = @config[:SSLStartImmediately] |
