Class: Reel::SSLServer
Constant Summary
Constants inherited from Server
Instance Method Summary collapse
-
#initialize(host, port, options = {}, &callback) ⇒ SSLServer
constructor
A new instance of SSLServer.
- #run ⇒ Object
Methods inherited from Server
Constructor Details
#initialize(host, port, options = {}, &callback) ⇒ SSLServer
Returns a new instance of SSLServer.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/reel/ssl_server.rb', line 5 def initialize(host, port, = {}, &callback) backlog = .fetch(:backlog, DEFAULT_BACKLOG) # Ideally we can encapsulate this rather than making Ruby OpenSSL a # mandatory part of the Reel API. It would be nice to support # alternatives (e.g. Puma's MiniSSL) ssl_context = OpenSSL::SSL::SSLContext.new ssl_context.cert = OpenSSL::X509::Certificate.new .fetch(:cert) ssl_context.key = OpenSSL::PKey::RSA.new .fetch(:key) # We don't presently support verifying client certificates # TODO: support client certificates! ssl_context.verify_mode = OpenSSL::SSL::VERIFY_NONE @tcpserver = Celluloid::IO::TCPServer.new(host, port) @server = Celluloid::IO::SSLServer.new(@tcpserver, ssl_context) @server.listen(backlog) @callback = callback async.run end |