A socket class for SSL connections. Please note that this class internally uses the #on_connect callback for doing SSL setup. If you would like a callback when the SSL connection is completed, please use the #on_ssl_connect callback instead. If you really need a callback which fires before SSL setup begins, use #on_connect but be sure to call super.
Called when peer certificate has successfully been received. Equivalent to OpenSSL::SSL::SSLSocket#peer_cert
# File lib/rev/ssl.rb, line 154 def on_peer_cert(peer_cert); end
Called when SSL handshaking has successfully completed
# File lib/rev/ssl.rb, line 149 def on_ssl_connect; end
Called if an error occurs during SSL session initialization
# File lib/rev/ssl.rb, line 163 def on_ssl_error(exception); end
Called when SSL handshaking has been completed successfully. Equivalent to OpenSSL::SSL::SSLSocket#verify_result
# File lib/rev/ssl.rb, line 159 def on_ssl_result(result); end
Returns the OpenSSL::SSL::SSLContext for to use for the session. By default no certificates will be checked. If you would like any certificate checking to be performed, please override this method and return a context loaded with the appropriate certificates.
# File lib/rev/ssl.rb, line 144 def ssl_context @_ssl_context ||= OpenSSL::SSL::SSLContext.new end
# File lib/rev/ssl.rb, line 170 def on_connect extend SSL @_connecting ? ssl_client_start : ssl_server_start end
Perform a non-blocking connect to the given host and port
# File lib/rev/ssl.rb, line 134 def self.connect(addr, port, *args) sock = super sock.instance_variable_set(:@_connecting, true) sock end