Class: Rev::SSLSocket

Inherits:
TCPSocket show all
Defined in:
lib/rev/ssl.rb

Overview

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.

Constant Summary

Constants inherited from IO

IO::INPUT_SIZE

Instance Attribute Summary

Attributes inherited from TCPSocket

#address_family, #remote_addr, #remote_host, #remote_port

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from TCPSocket

#initialize, #peeraddr, precreate

Methods inherited from Socket

#attach, #on_connect_failed, #on_resolve_failed

Methods inherited from IO

#attach, #attached?, #close, #closed?, #detach, #disable, #enable, #enabled?, #evloop, #initialize, #on_close, #on_read, #on_write_complete, #output_buffer_size, #write

Methods included from Meta

#event_callback, #watcher_delegate

Constructor Details

This class inherits a constructor from Rev::TCPSocket

Class Method Details

.connect(addr, port, *args) ⇒ Object

Perform a non-blocking connect to the given host and port



134
135
136
137
138
# File 'lib/rev/ssl.rb', line 134

def self.connect(addr, port, *args)
  sock = super
  sock.instance_variable_set(:@_connecting, true)
  sock
end

Instance Method Details

#on_peer_cert(peer_cert) ⇒ Object

Called when peer certificate has successfully been received. Equivalent to OpenSSL::SSL::SSLSocket#peer_cert



154
# File 'lib/rev/ssl.rb', line 154

def on_peer_cert(peer_cert); end

#on_ssl_connectObject

Called when SSL handshaking has successfully completed



149
# File 'lib/rev/ssl.rb', line 149

def on_ssl_connect; end

#on_ssl_error(exception) ⇒ Object

Called if an error occurs during SSL session initialization



163
# File 'lib/rev/ssl.rb', line 163

def on_ssl_error(exception); end

#on_ssl_result(result) ⇒ Object

Called when SSL handshaking has been completed successfully. Equivalent to OpenSSL::SSL::SSLSocket#verify_result



159
# File 'lib/rev/ssl.rb', line 159

def on_ssl_result(result);  end

#ssl_contextObject

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.



144
145
146
# File 'lib/rev/ssl.rb', line 144

def ssl_context
  @_ssl_context ||= OpenSSL::SSL::SSLContext.new
end