Manage private and public keys as a pair.
# File lib/puppet/ssl/key.rb, line 25 def initialize(name) super if ca? @password_file = Puppet[:capass] else @password_file = Puppet[:passfile] end end
Because of how the format handler class is included, this can’t be in the base class.
# File lib/puppet/ssl/key.rb, line 13 def self.supported_formats [:s] end
Knows how to create keys with our system defaults.
# File lib/puppet/ssl/key.rb, line 20 def generate Puppet.info "Creating a new SSL key for #{name}" @content = OpenSSL::PKey::RSA.new(Puppet[:keylength].to_i) end
# File lib/puppet/ssl/key.rb, line 35 def password return nil unless password_file and FileTest.exist?(password_file) ::File.read(password_file) end
Optionally support specifying a password file.
# File lib/puppet/ssl/key.rb, line 42 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
# File lib/puppet/ssl/key.rb, line 49 def to_s if pass = password @content.export(OpenSSL::Cipher::DES.new(:EDE3, :CBC), pass) else return super end end