summaryrefslogtreecommitdiff
path: root/lib/webrick/https.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/webrick/https.rb')
-rw-r--r--lib/webrick/https.rb48
1 files changed, 48 insertions, 0 deletions
diff --git a/lib/webrick/https.rb b/lib/webrick/https.rb
index 73875d7326..1494973e74 100644
--- a/lib/webrick/https.rb
+++ b/lib/webrick/https.rb
@@ -10,6 +10,7 @@
# $IPR: https.rb,v 1.15 2003/07/22 19:20:42 gotoyuzo Exp $
require 'webrick/ssl'
+require 'webrick/httpserver'
module WEBrick
module Config
@@ -84,4 +85,51 @@ module WEBrick
# :startdoc:
end
+
+ ##
+ #--
+ # Fake WEBrick::HTTPRequest for lookup_server
+
+ class SNIRequest
+
+ ##
+ # The SNI hostname
+
+ attr_reader :host
+
+ ##
+ # The socket address of the server
+
+ attr_reader :addr
+
+ ##
+ # The port this request is for
+
+ attr_reader :port
+
+ ##
+ # Creates a new SNIRequest.
+
+ def initialize(sslsocket, hostname)
+ @host = hostname
+ @addr = sslsocket.addr
+ @port = @addr[1]
+ end
+ end
+
+
+ ##
+ #--
+ # Adds SSL functionality to WEBrick::HTTPServer
+
+ class HTTPServer < ::WEBrick::GenericServer
+ ##
+ # ServerNameIndication callback
+
+ def ssl_servername_callback(sslsocket, hostname = nil)
+ req = SNIRequest.new(sslsocket, hostname)
+ server = lookup_server(req)
+ server ? server.ssl_context : nil
+ end
+ end
end