Module: Ronin::Support::Network::SSL::LocalKey Private

Defined in:
lib/ronin/support/network/ssl/local_key.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Represents the RSA signing key used for local SSL server sockets.

Constant Summary collapse

PATH =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

The cached ~/.local/share/ronin/ssl.key file.

File.join(Home::LOCAL_SHARE_DIR,'ronin','ronin-support','ssl.key')

Class Method Summary collapse

Class Method Details

.fetchCrypto::Key::RSA

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The default RSA key used for all SSL server sockets.

Returns:



75
76
77
78
79
# File 'lib/ronin/support/network/ssl/local_key.rb', line 75

def self.fetch
  if File.file?(PATH) then load
  else                     generate
  end
end

.generateCrypto::Key::RSA

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Note:

The file will be created with a chmod umask of 0640 (aka -rw-r-----).

Generates a new RSA key and saves it to ~/.local/share/ronin/ssl.key.

Returns:



48
49
50
51
52
53
54
55
56
57
# File 'lib/ronin/support/network/ssl/local_key.rb', line 48

def self.generate
  key = Crypto::Key::RSA.generate

  FileUtils.mkdir_p(File.dirname(PATH))
  FileUtils.touch(PATH)
  FileUtils.chmod(0640,PATH)

  key.save(PATH)
  return key
end

.loadCrypto::Key::RSA

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Loads the RSA key from ~/.local/share/ronin/ssl.key.

Returns:



65
66
67
# File 'lib/ronin/support/network/ssl/local_key.rb', line 65

def self.load
  Crypto::Key::RSA.load_file(PATH)
end