Module: EventMachine::IMAP::DeferrableSSL

Included in:
Connection
Defined in:
lib/em-imap/deferrable_ssl.rb

Overview

By default it’s hard to tell when the SSL handshake has finished. We thus wrap start_tls so that it returns a deferrable that will tell us when it’s done.

Instance Method Summary collapse

Instance Method Details

#ssl_handshake_completedObject

Hook into ssl_handshake_completed so that we know when to succeed the deferrable we returned above.



23
24
25
26
# File 'lib/em-imap/deferrable_ssl.rb', line 23

def ssl_handshake_completed
  @ssl_deferrable.succeed
  super
end

#start_tlsObject

Run a TLS handshake and return a deferrable that succeeds when it’s finished

TODO: expose certificates so they can be verified.



12
13
14
15
16
17
18
19
# File 'lib/em-imap/deferrable_ssl.rb', line 12

def start_tls
  unless @ssl_deferrable
    @ssl_deferrable = DG::blank
    bothback{ @ssl_deferrable.fail }
    super
  end
  @ssl_deferrable
end