From a6c13d08d7d2035a22855c8f412694d13ba2faa0 Mon Sep 17 00:00:00 2001 From: normal Date: Tue, 18 Jul 2017 01:59:28 +0000 Subject: webrick: fix SNI support * lib/webrick/https.rb: check ssl context of virtual host. * lib/webrick/ssl.rb: ensure to return ssl context. * test/webrick/test_https.rb: test returned cert is correct. [Feature #13729][ruby-dev:50173] Author: Tietew git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59351 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/webrick/https.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'lib/webrick/https.rb') 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 -- cgit v1.2.3