class Rev::SSLSocket

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.

Public Instance Methods

on_peer_cert(peer_cert) click to toggle source

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
on_ssl_connect() click to toggle source

Called when SSL handshaking has successfully completed

# File lib/rev/ssl.rb, line 149
def on_ssl_connect; end
on_ssl_error(exception) click to toggle source

Called if an error occurs during SSL session initialization

# File lib/rev/ssl.rb, line 163
def on_ssl_error(exception); end
on_ssl_result(result) click to toggle source

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
ssl_context() click to toggle source

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

Protected Instance Methods

on_connect() click to toggle source
# File lib/rev/ssl.rb, line 170
def on_connect
  extend SSL
  @_connecting ? ssl_client_start : ssl_server_start
end

Public Class Methods

connect(addr, port, *args) click to toggle source

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