Module: IOMultiplex::Mixins::OpenSSL
- Included in:
- IOReactor::OpenSSL, IOReactor::OpenSSLUpgrading
- Defined in:
- lib/iomultiplex/mixins/openssl.rb
Overview
OpenSSL mixin, shared code amongst the OpenSSL IOReactors
Instance Method Summary collapse
- #handle_read ⇒ Object
- #handle_write ⇒ Object
- #handshake_completed? ⇒ Boolean
- #peer_cert ⇒ Object
- #peer_cert_cn ⇒ Object
Instance Method Details
#handle_read ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/iomultiplex/mixins/openssl.rb', line 23 def handle_read if @write_on_read handle_write # Still need more reads to complete a write? return if @write_on_read end super # If we were waiting for a write signal so we could complete a read # call, clear it since we now completed it reset_read_on_write if @read_on_write rescue IO::WaitWritable # TODO: handle_data should really be triggered # This captures an OpenSSL read wanting a write @multiplexer.stop_read self @multiplexer.wait_write self @read_on_write = true log_debug 'OpenSSL wants read on write' end |
#handle_write ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/iomultiplex/mixins/openssl.rb', line 46 def handle_write if @read_on_write handle_read # Still need more writes to complete a read? return if @read_on_write end super # If we were waiting for a read signal so we could complete a write # call, clear it since we now completed it reset_write_on_read if @write_on_read rescue IO::WaitReadable # Write needs a read @multiplexer.stop_write self @multiplexer.wait_read self @write_on_read = true log_debug 'OpenSSL wants write on read' end |
#handshake_completed? ⇒ Boolean
81 82 83 |
# File 'lib/iomultiplex/mixins/openssl.rb', line 81 def handshake_completed? @handshake_completed end |
#peer_cert ⇒ Object
68 69 70 |
# File 'lib/iomultiplex/mixins/openssl.rb', line 68 def peer_cert @ssl.peer_cert end |
#peer_cert_cn ⇒ Object
72 73 74 75 76 77 78 79 |
# File 'lib/iomultiplex/mixins/openssl.rb', line 72 def peer_cert_cn return nil unless peer_cert return @peer_cert_cn unless @peer_cert_cn.nil? @peer_cert_cn = peer_cert.subject.to_a.find do |oid, value| return value if oid == 'CN' nil end end |