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
13 def initialize(path)
14   @path = path
15   @custom_attributes = {}
16   @extension_requests = {}
17 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
22 def load
23   Puppet.info(_("csr_attributes file loading from %{path}") % { path: path })
24   if Puppet::FileSystem.exist?(path)
25     hash = Puppet::Util::Yaml.safe_load_file(path, [Symbol]) || {}
26     if ! hash.is_a?(Hash)
27       raise Puppet::Error, _("invalid CSR attributes, expected instance of Hash, received instance of %{klass}") % { klass: hash.class }
28     end
29     @custom_attributes = hash.delete('custom_attributes') || {}
30     @extension_requests = hash.delete('extension_requests') || {}
31     if not hash.keys.empty?
32       raise Puppet::Error, _("unexpected attributes %{keys} in %{path}") % { keys: hash.keys.inspect, path: @path.inspect }
33     end
34     return true
35   end
36   return false
37 end