Module: Rev::SSL
- Defined in:
- lib/rev/ssl.rb,
ext/rev/rev_ssl.c
Overview
The easiest way to add SSL support to your Rev applications is to use the SSLSocket class. However, the SSL module is provided for cases where you’ve already subclassed TCPSocket and want to optionally provide SSL support in that class.
This module monkeypatches Rev::IO to include SSL support. This can be accomplished by extending any Rev:IO (or subclass) object with Rev::SSL after the connection has completed, e.g.
class MySocket < Rev::TCPSocket
def on_connect
extend Rev::SSL
ssl_client_start
end
end
Defined Under Namespace
Classes: IO
Instance Method Summary collapse
-
#ssl_client_start ⇒ Object
Start SSL explicitly in client mode.
-
#ssl_server_start ⇒ Object
Start SSL explicitly in server mode.
Instance Method Details
#ssl_client_start ⇒ Object
Start SSL explicitly in client mode. After calling this, callbacks will fire for checking the peer certificate (ssl_peer_cert) and its validity (ssl_verify_result)
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/rev/ssl.rb', line 30 def ssl_client_start raise "ssl already started" if @_ssl_socket context = respond_to?(:ssl_context) ? ssl_context : OpenSSL::SSL::SSLContext.new @_ssl_socket = SSL::IO.new(@_io, context) @_ssl_init = proc { @_ssl_socket.connect_nonblock } ssl_init end |
#ssl_server_start ⇒ Object
Start SSL explicitly in server mode. After calling this, callbacks will fire for checking the peer certificate (ssl_peer_cert) and its validity (ssl_verify_result)
44 45 46 47 48 49 50 51 |
# File 'lib/rev/ssl.rb', line 44 def ssl_server_start raise "ssl already started" if @_ssl_socket @_ssl_socket = SSL::IO.new(@_io, ssl_context) @_ssl_init = proc { @_ssl_socket.accept_nonblock } ssl_init end |