module Unicorn::SSLServer - unicorn-4.9.0 Documentation

# module Unicorn::SSLServer

this module is meant to be included in Unicorn::HttpServer It is an implementation detail and NOT meant for users.

### Attributes

ssl_engine[RW]

### Public Instance Methods

ssl_enable!() click to toggle source

    # File lib/unicorn/ssl_server.rb, line 7
    def ssl_enable!
      sni_hostnames = rack_sni_hostnames(@app)
      seen = {} # we map a single SSLContext to multiple listeners
      listener_ctx = {}
      @listener_opts.each do |address, address_opts|
        ssl_opts = address_opts[:ssl_opts] or next
        listener_ctx[address] = seen[ssl_opts.object_id] ||= begin
          unless sni_hostnames.empty?
            ssl_opts = ssl_opts.dup
            ssl_opts[:sni_hostnames] = sni_hostnames
          end
          ctx = Flipper.ssl_context(ssl_opts)
          # FIXME: make configurable
          ctx.session_cache_mode = OpenSSL::SSL::SSLContext::SESSION_CACHE_OFF
          ctx
        end
      end
      Unicorn::HttpServer::LISTENERS.each do |listener|
        ctx = listener_ctx[sock_name(listener)] or next
        listener.extend(Kgio::SSLServer)
        listener.ssl_ctx = ctx
        listener.kgio_ssl_class = Unicorn::SSLClient
      end
    end