Class: Puppet::SSL::Key
- Extended by:
- Indirector
- Defined in:
- lib/vendor/puppet/ssl/key.rb
Overview
Manage private and public keys as a pair.
Defined Under Namespace
Classes: Ca, DisabledCa, File
Constant Summary
Constants included from Indirector
Constants inherited from Base
Base::SEPARATOR, Base::VALID_CERTNAME
Instance Attribute Summary collapse
-
#password_file ⇒ Object
Returns the value of attribute password_file.
Attributes inherited from Base
Class Method Summary collapse
-
.supported_formats ⇒ Object
Because of how the format handler class is included, this can’t be in the base class.
Instance Method Summary collapse
-
#generate ⇒ Object
Knows how to create keys with our system defaults.
-
#initialize(name) ⇒ Key
constructor
A new instance of Key.
- #password ⇒ Object
-
#read(path) ⇒ Object
Optionally support specifying a password file.
- #to_s ⇒ Object
Methods included from Indirector
Methods inherited from Base
#ca?, #fingerprint, from_multiple_s, to_multiple_s, #to_text, validate_certname, wrapped_class, wraps
Constructor Details
Instance Attribute Details
#password_file ⇒ Object
Returns the value of attribute password_file.
17 18 19 |
# File 'lib/vendor/puppet/ssl/key.rb', line 17 def password_file @password_file end |
Class Method Details
.supported_formats ⇒ Object
Because of how the format handler class is included, this can’t be in the base class.
13 14 15 |
# File 'lib/vendor/puppet/ssl/key.rb', line 13 def self.supported_formats [:s] end |
Instance Method Details
#generate ⇒ Object
Knows how to create keys with our system defaults.
20 21 22 23 |
# File 'lib/vendor/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 |
#password ⇒ Object
35 36 37 38 39 |
# File 'lib/vendor/puppet/ssl/key.rb', line 35 def password return nil unless password_file and FileTest.exist?(password_file) ::File.read(password_file) end |
#read(path) ⇒ Object
Optionally support specifying a password file.
42 43 44 45 46 47 |
# File 'lib/vendor/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 |
#to_s ⇒ Object
49 50 51 52 53 54 55 |
# File 'lib/vendor/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 |