Class: IOMultiplex::IOReactor::OpenSSLUpgrading

Inherits:
Buffered show all
Includes:
Mixins::OpenSSL
Defined in:
lib/iomultiplex/ioreactor/openssl.rb

Overview

OpenSSLUpgrading wraps an IO object that acts like a regular IOReactor but can be upgraded to a TLS connection mid-connection

Constant Summary

Constants included from Mixins::IOReactor::Write

Mixins::IOReactor::Write::WRITE_BUFFER_MAX, Mixins::IOReactor::Write::WRITE_SIZE

Constants included from Mixins::IOReactor::Read

Mixins::IOReactor::Read::READ_BUFFER_MAX, Mixins::IOReactor::Read::READ_SIZE

Instance Attribute Summary

Attributes inherited from IOMultiplex::IOReactor

#id, #io, #mode, #peer

Attributes included from Mixins::Logger

#logger, #logger_context

Instance Method Summary collapse

Methods included from Mixins::OpenSSL

#handle_read, #handle_write, #handshake_completed?, #peer_cert, #peer_cert_cn

Methods inherited from IOMultiplex::IOReactor

#addr, #attach, #close, #detach, #force_close, #peeraddr

Methods included from Mixins::IOReactor::Write

#handle_write, #write, #write_full?

Methods included from Mixins::IOReactor::Read

#discard, #handle_data, #handle_read, #pause, #read, #read_full?, #resume

Constructor Details

#initialize(io, _ = nil, id = nil) ⇒ OpenSSLUpgrading

Returns a new instance of OpenSSLUpgrading.



56
57
58
59
60
61
# File 'lib/iomultiplex/ioreactor/openssl.rb', line 56

def initialize(io, _ = nil, id = nil)
  # OpenSSL is implicitly read/write due to key-exchange so we ignore the
  # mode parameter
  super io, 'rw', id
  @ssl_enabled = false
end

Instance Method Details

#start_ssl(ssl_ctx) ⇒ Object

Raises:

  • ('SSL already started')


63
64
65
66
67
68
69
# File 'lib/iomultiplex/ioreactor/openssl.rb', line 63

def start_ssl(ssl_ctx)
  raise 'SSL already started', nil if @ssl_enabled
  initialize_ssl ssl_ctx
  @ssl_enabled = true
  log_debug 'Upgrading connection to SSL'
  nil
end