Sha256: ea0f6cbc0d70aecd79e1a3ba6e44644948eab829d80950e8540e261e0b59c71f

Contents?: true

Size: 1.07 KB

Versions: 96

Compression:

Stored size: 1.07 KB

Contents

require 'puppet/indirector/ssl_file'
require 'puppet/ssl/key'

class Puppet::SSL::Key::File < Puppet::Indirector::SslFile
  desc "Manage SSL private and public keys on disk."

  store_in :privatekeydir
  store_ca_at :cakey

  # Where should we store the public key?
  def public_key_path(name)
    if ca?(name)
      Puppet[:capub]
    else
      File.join(Puppet[:publickeydir], name.to_s + ".pem")
    end
  end

  # Remove the public key, in addition to the private key
  def destroy(request)
    super

    return unless FileTest.exist?(public_key_path(request.key))

    begin
      File.unlink(public_key_path(request.key))
    rescue => detail
      raise Puppet::Error, "Could not remove #{request.key} public key: #{detail}"
    end
  end

  # Save the public key, in addition to the private key.
  def save(request)
    super

    begin
      Puppet.settings.writesub(:publickeydir, public_key_path(request.key)) { |f| f.print request.instance.content.public_key.to_pem }
    rescue => detail
      raise Puppet::Error, "Could not write #{request.key}: #{detail}"
    end
  end
end

Version data entries

96 entries across 96 versions & 4 rubygems

Version Path
puppet-2.7.17 lib/puppet/indirector/key/file.rb
puppet-2.7.16 lib/puppet/indirector/key/file.rb
puppet-2.7.14 lib/puppet/indirector/key/file.rb
puppet-2.6.16 lib/puppet/indirector/key/file.rb
puppet-2.7.13 lib/puppet/indirector/key/file.rb
puppet-2.6.15 lib/puppet/indirector/key/file.rb
supply_drop-0.9.0 examples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/indirector/key/file.rb
supply_drop-0.8.1 examples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/indirector/key/file.rb
supply_drop-0.8.0 examples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/indirector/key/file.rb
puppet-2.7.12 lib/puppet/indirector/key/file.rb
puppet-2.7.11 lib/puppet/indirector/key/file.rb
puppet-2.6.14 lib/puppet/indirector/key/file.rb
supply_drop-0.7.0 examples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/indirector/key/file.rb
supply_drop-0.6.1 examples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/indirector/key/file.rb
supply_drop-0.6.0 examples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/indirector/key/file.rb
puppet-2.6.13 lib/puppet/indirector/key/file.rb
puppet-2.7.9 lib/puppet/indirector/key/file.rb
puppet-2.7.8 lib/puppet/indirector/key/file.rb
puppet-2.7.6 lib/puppet/indirector/key/file.rb
puppet-2.6.12 lib/puppet/indirector/key/file.rb