Class: Reel::Server::HTTPS
- Inherits:
-
Reel::Server
- Object
- Reel::Server
- Reel::Server::HTTPS
- Defined in:
- lib/reel/server/https.rb
Constant Summary
Constants inherited from Reel::Server
Instance Method Summary collapse
-
#initialize(host, port, options = {}, &callback) ⇒ Reel::Server::HTTPS
constructor
Create a new Reel HTTPS server.
- #run ⇒ Object
Methods inherited from Reel::Server
Constructor Details
#initialize(host, port, options = {}, &callback) ⇒ Reel::Server::HTTPS
Create a new Reel HTTPS server
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/reel/server/https.rb', line 15 def initialize(host, port, ={}, &callback) # 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) ssl_context.ca_file = [:ca_file] ssl_context.ca_path = [:ca_path] ssl_context.extra_chain_cert = [:extra_chain_cert] # if verify_mode isn't explicitly set, verify peers if we've # been provided CA information that would enable us to do so ssl_context.verify_mode = case when .include?(:verify_mode) [:verify_mode] when .include?(:ca_file) OpenSSL::SSL::VERIFY_PEER when .include?(:ca_path) OpenSSL::SSL::VERIFY_PEER else OpenSSL::SSL::VERIFY_NONE end @tcpserver = Celluloid::IO::TCPServer.new(host, port) server = Celluloid::IO::SSLServer.new(@tcpserver, ssl_context) .merge!(host: host, port: port) super(server, , &callback) end |
Instance Method Details
#run ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/reel/server/https.rb', line 49 def run loop do begin socket = @server.accept rescue OpenSSL::SSL::SSLError, Errno::ECONNRESET, Errno::EPIPE, Errno::ETIMEDOUT, Errno::EHOSTUNREACH => ex Logger.warn "Error accepting SSLSocket: #{ex.class}: #{ex.to_s}" retry end async.handle_connection socket end end |