class Puppet::SSL::Key

Manage private and public keys as a pair.

Public Instance Methods

generate() click to toggle source

Knows how to create keys with our system defaults.

# File lib/puppet/ssl/key.rb, line 23
def generate
  Puppet.info "Creating a new SSL key for #{name}"
  @content = OpenSSL::PKey::RSA.new(Puppet[:keylength].to_i)
end
password() click to toggle source
# File lib/puppet/ssl/key.rb, line 38
def password
  return nil unless password_file and Puppet::FileSystem.exist?(password_file)

  ::File.read(password_file)
end
read(path) click to toggle source

Optionally support specifying a password file.

# File lib/puppet/ssl/key.rb, line 45
def read(path)
  return super unless password_file

  #@content = wrapped_class.new(::File.read(path), password)
  @content = wrapped_class.new(::File.read(path), password)
end
to_s() click to toggle source
# File lib/puppet/ssl/key.rb, line 52
def to_s
  if pass = password
    @content.export(OpenSSL::Cipher::DES.new(:EDE3, :CBC), pass)
  else
    return super
  end
end

Public Class Methods

new(name) click to toggle source
# File lib/puppet/ssl/key.rb, line 28
def initialize(name)
  super

  if ca?
    @password_file = Puppet[:capass]
  else
    @password_file = Puppet[:passfile]
  end
end
supported_formats() click to toggle source

Because of how the format handler class is included, this can’t be in the base class.

# File lib/puppet/ssl/key.rb, line 16
def self.supported_formats
  [:s]
end