Module: ForemanX509::Extensions

Extended by:
ActiveSupport::Concern
Included in:
Certificate, Issuer
Defined in:
app/models/concerns/foreman_x509/extensions.rb

Constant Summary collapse

EXTENSION_ENTRY_FORMAT =
/\A(?<critical>critical,)?\s*(?:@(?<section>[a-zA-Z_]+)|(?<value>[^@].*))\Z/.freeze

Instance Method Summary collapse

Instance Method Details

#extension_value_from_section(section) ⇒ Object



16
17
18
# File 'app/models/concerns/foreman_x509/extensions.rb', line 16

def extension_value_from_section(section)
  configuration[section].entries.map { |entry| entry.join(':') }.join(',')
end

#extensions_from_section(section) ⇒ Object



7
8
9
10
11
12
13
14
# File 'app/models/concerns/foreman_x509/extensions.rb', line 7

def extensions_from_section(section)
  return {} if section.nil?

  configuration[section].transform_values do |value|
    data = EXTENSION_ENTRY_FORMAT.match(value)
    data[:critical].to_s + (data[:value] || extension_value_from_section(data[:section])).to_s
  end
end