Sha256: eb5befcf6999f9893913d499cb8a8609c827a377fbfe425a8db6ad55fd8d7264

Contents?: true

Size: 1.18 KB

Versions: 6

Compression:

Stored size: 1.18 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 %s public key: %s" % [request.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 %s: %s" % [request.key, detail]
        end
    end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
puppet-0.25.5 lib/puppet/indirector/key/file.rb
puppet-0.25.4 lib/puppet/indirector/key/file.rb
puppet-0.25.3 lib/puppet/indirector/key/file.rb
puppet-0.25.2 lib/puppet/indirector/key/file.rb
puppet-0.25.1 lib/puppet/indirector/key/file.rb
puppet-0.25.0 lib/puppet/indirector/key/file.rb