Sha256: 19771c06468e1dacc5d1bd16f3bc35ee6d193af16e558e5ea00b096a53302926

Contents?: true

Size: 1.24 KB

Versions: 80

Compression:

Stored size: 1.24 KB

Contents

require 'puppet/ssl/base'
require 'puppet/indirector'

# Manage private and public keys as a pair.
class Puppet::SSL::Key < Puppet::SSL::Base
  wraps OpenSSL::PKey::RSA

  extend Puppet::Indirector
  indirects :key, :terminus_class => :file

  # Because of how the format handler class is included, this
  # can't be in the base class.
  def self.supported_formats
    [:s]
  end

  attr_accessor :password_file

  # Knows how to create keys with our system defaults.
  def generate
    Puppet.info "Creating a new SSL key for #{name}"
    @content = OpenSSL::PKey::RSA.new(Puppet[:keylength].to_i)
  end

  def initialize(name)
    super

    if ca?
      @password_file = Puppet[:capass]
    else
      @password_file = Puppet[:passfile]
    end
  end

  def password
    return nil unless password_file and FileTest.exist?(password_file)

    ::File.read(password_file)
  end

  # Optionally support specifying a password file.
  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

  def to_s
    if pass = password
      @content.export(OpenSSL::Cipher::DES.new(:EDE3, :CBC), pass)
    else
      return super
    end
  end
end

Version data entries

80 entries across 80 versions & 4 rubygems

Version Path
puppet-parse-0.1.4 lib/vendor/puppet/ssl/key.rb
puppet-parse-0.1.3 lib/vendor/puppet/ssl/key.rb
puppet-parse-0.1.2 lib/vendor/puppet/ssl/key.rb
puppet-parse-0.1.1 lib/vendor/puppet/ssl/key.rb
puppet-2.7.26 lib/puppet/ssl/key.rb
puppet-2.7.25 lib/puppet/ssl/key.rb
puppet-2.7.24 lib/puppet/ssl/key.rb
puppet-2.7.23 lib/puppet/ssl/key.rb
puppet-2.7.22 lib/puppet/ssl/key.rb
librarian-puppet-0.9.9 vendor/gems/ruby/1.9.1/gems/puppet-3.1.0/lib/puppet/ssl/key.rb
puppet-parse-0.1.0 lib/vendor/puppet/ssl/key.rb
puppet-parse-0.0.6 lib/vendor/puppet/ssl/key.rb
puppet-2.7.21 lib/puppet/ssl/key.rb
puppet-3.1.1 lib/puppet/ssl/key.rb
puppet-2.6.18 lib/puppet/ssl/key.rb
puppet-parse-0.0.5 lib/vendor/puppet/ssl/key.rb
puppet-parse-0.0.4 lib/vendor/puppet/ssl/key.rb
librarian-puppet-0.9.8 vendor/gems/ruby/1.9.1/gems/puppet-3.1.0/lib/puppet/ssl/key.rb
puppet-3.1.0 lib/puppet/ssl/key.rb
puppet-3.1.0.rc2 lib/puppet/ssl/key.rb