class Key::File

Public Instance Methods

destroy(request) click to toggle source

Remove the public key, in addition to the private key

Calls superclass method Puppet::Indirector::SslFile#destroy
# File lib/puppet/indirector/key/file.rb, line 20
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
public_key_path(name) click to toggle source

Where should we store the public key?

# File lib/puppet/indirector/key/file.rb, line 11
def public_key_path(name)
  if ca?(name)
    Puppet[:capub]
  else
    File.join(Puppet[:publickeydir], name.to_s + ".pem")
  end
end
save(request) click to toggle source

Save the public key, in addition to the private key.

Calls superclass method Puppet::Indirector::SslFile#save
# File lib/puppet/indirector/key/file.rb, line 33
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