Class: ForemanX509::Issuer
- Inherits:
-
ApplicationRecord
- Object
- ApplicationRecord
- ForemanX509::Issuer
show all
- Includes:
- Digest, Extensions, Subject
- Defined in:
- app/models/foreman_x509/issuer.rb
Constant Summary
Constants included
from Extensions
Extensions::EXTENSION_ENTRY_FORMAT
Instance Method Summary
collapse
Methods included from Digest
#digest
Methods included from Extensions
#extension_value_from_section, #extensions_from_section
Methods included from Subject
#subject, #subject_from_certificate, #subject_from_configuration
Instance Method Details
#bundle ⇒ Object
63
64
65
66
67
|
# File 'app/models/foreman_x509/issuer.rb', line 63
def bundle
return [ certificate.certificate ] if certificate.issuer.nil? or certificate.issuer == self
[ certificate.certificate ] + certificate.issuer.bundle
end
|
#certificate_extensions(requested_extensions, section = nil) ⇒ Object
51
52
53
54
55
56
57
58
59
60
61
|
# File 'app/models/foreman_x509/issuer.rb', line 51
def certificate_extensions(requested_extensions, section = nil)
section ||= default_certificate_extensions_section
case copy_extensions
when 'copy'
requested_extensions.merge(extensions_from_section(section))
when 'copyall'
extensions_from_section(section).merge(requested_extensions)
else extensions_from_section(section)
end
end
|
#end_date ⇒ Object
41
42
43
44
45
46
47
48
49
|
# File 'app/models/foreman_x509/issuer.rb', line 41
def end_date
end_date = configuration.get_value(authority_section, 'default_enddate')
if end_date.nil?
duration = configuration.get_value(authority_section, 'default_days')
start_date + (duration.nil? ? 3650.days : duration.to_i.days) else
Time.parse(end_date)
end
end
|
#external? ⇒ Boolean
21
22
23
|
# File 'app/models/foreman_x509/issuer.rb', line 21
def external?
configuration.nil?
end
|
#self_signing? ⇒ Boolean
25
26
27
|
# File 'app/models/foreman_x509/issuer.rb', line 25
def self_signing?
certificate.issuer == self
end
|
#serial! ⇒ Object
29
30
31
32
33
|
# File 'app/models/foreman_x509/issuer.rb', line 29
def serial!
next_serial = serial || SecureRandom.hex(16)
update_attribute(:serial, next_serial + 1) unless new_record?
next_serial
end
|
#start_date ⇒ Object
35
36
37
38
39
|
# File 'app/models/foreman_x509/issuer.rb', line 35
def start_date
start_date = configuration.get_value(authority_section, 'default_startdate')
start_date = Time.parse(start_date) unless start_date.nil?
start_date || Time.now
end
|