Module: Ronin::Network::Mixins::SSL

Includes:
Mixin, SSL
Defined in:
lib/ronin/network/mixins/ssl.rb

Overview

Adds SSL convenience methods and connection parameters to a class.

Defines the following parameters:

  • host (String) - SSL host.
  • port (Integer) - SSL port.
  • local_host (String) - SSL local host.
  • local_port (Integer) - SSL local port.

Since:

  • 0.4.0

Constant Summary

Constants included from SSL

SSL::VERIFY

Instance Method Summary collapse

Methods included from Mixin

included

Methods included from TCP

#tcp_accept, #tcp_banner, #tcp_connect, #tcp_connect_and_send, #tcp_open?, #tcp_send, #tcp_server, #tcp_server_loop, #tcp_server_session, #tcp_session, #tcp_single_server

Instance Method Details

#ssl_connect(host, port, options = {}) {|ssl_socket| ... } ⇒ OpenSSL::SSL::SSLSocket (protected)

Establishes a SSL connection.

Examples:

socket = ssl_connect

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :verify (Symbol)

    Specifies whether to verify the SSL certificate. May be one of the following:

    • :none
    • :peer
    • :client_once
    • :fail_if_no_peer_cert
  • :cert (String)

    The path to the SSL certificate.

  • :key (String)

    The path to the SSL key.

Yields:

  • (ssl_socket)

    The given block will be passed the new SSL Socket.

Yield Parameters:

  • ssl_socket (OpenSSL::SSL::SSLSocket)

    The new SSL Socket.

Returns:

  • (OpenSSL::SSL::SSLSocket)

    the new SSL Socket.

See Also:

Since:

  • 0.4.0


93
94
95
96
97
98
99
100
# File 'lib/ronin/network/mixins/ssl.rb', line 93

def ssl_connect(host,port,options={},&block)
  options = options.merge(
    :local_host => self.local_host,
    :local_port => self.local_port
  )

  super(self.host,self.port,options,&block)
end

#ssl_session(options = {}) {|ssl_socket| ... } ⇒ nil (protected)

Creates a new temporary SSL connection.

Examples:

ssl_session do |socket|
  socket.write("GET / HTTP/1.1\n\r\n\r")

  socket.each_line { |line| puts line }
end

Parameters:

  • options (Hash) (defaults to: {})

    Additional options.

Options Hash (options):

  • :local_host (String)

    The local host to bind to.

  • :local_port (Integer)

    The local port to bind to.

  • :verify (Symbol)

    Specifies whether to verify the SSL certificate.

  • :cert (String)

    The path to the SSL certificate.

  • :key (String)

    The path to the SSL key.

Yields:

  • (ssl_socket)

    The given block will be passed the temporary SSL Socket.

Yield Parameters:

  • ssl_socket (OpenSSL::SSL::SSLSocket)

    The temporary SSL Socket.

Returns:

  • (nil)

See Also:

Since:

  • 0.4.0


142
143
144
# File 'lib/ronin/network/mixins/ssl.rb', line 142

def ssl_session(options={},&block)
  super(self.host,self.port,options,&block)
end