class Puppet::SSL::CertificateRequestAttributes
This class transforms simple key/value pairs into the equivalent ASN1 structures. Values may be strings or arrays of strings.
@api private
Attributes
custom_attributes[R]
extension_requests[R]
path[R]
Public Class Methods
new(path)
click to toggle source
# File lib/puppet/ssl/certificate_request_attributes.rb 12 def initialize(path) 13 @path = path 14 @custom_attributes = {} 15 @extension_requests = {} 16 end
Public Instance Methods
load()
click to toggle source
Attempt to load a yaml file at the given @path. @return true if we are able to load the file, false otherwise @raise [Puppet::Error] if there are unexpected attribute keys
# File lib/puppet/ssl/certificate_request_attributes.rb 21 def load 22 Puppet.info(_("csr_attributes file loading from %{path}") % { path: path }) 23 if Puppet::FileSystem.exist?(path) 24 hash = Puppet::Util::Yaml.safe_load_file(path, [Symbol]) || {} 25 if ! hash.is_a?(Hash) 26 raise Puppet::Error, _("invalid CSR attributes, expected instance of Hash, received instance of %{klass}") % { klass: hash.class } 27 end 28 @custom_attributes = hash.delete('custom_attributes') || {} 29 @extension_requests = hash.delete('extension_requests') || {} 30 if not hash.keys.empty? 31 raise Puppet::Error, _("unexpected attributes %{keys} in %{path}") % { keys: hash.keys.inspect, path: @path.inspect } 32 end 33 return true 34 end 35 return false 36 end