Class: Ant::SSL::Configuration
- Inherits:
-
Object
- Object
- Ant::SSL::Configuration
- Defined in:
- lib/ant/ssl/configuration.rb
Overview
Stores a configuration for a certificate
Constant Summary collapse
- ONE_YEAR =
60 * 60 * 24 * 365
Instance Method Summary collapse
- #[](key) ⇒ Object
- #configure_cert_details!(cert) ⇒ Object
- #configure_extensions!(cert, extension_factory) ⇒ Object
- #crt_path ⇒ Object
-
#initialize(root, group, cert) ⇒ Configuration
constructor
A new instance of Configuration.
- #key_path ⇒ Object
- #saving_directory(type) ⇒ Object
- #subject_string ⇒ Object
Constructor Details
#initialize(root, group, cert) ⇒ Configuration
Returns a new instance of Configuration.
9 10 11 |
# File 'lib/ant/ssl/configuration.rb', line 9 def initialize(root, group, cert) @config = root.merge(group).merge(cert) end |
Instance Method Details
#[](key) ⇒ Object
52 53 54 |
# File 'lib/ant/ssl/configuration.rb', line 52 def [](key) @config[key] end |
#configure_cert_details!(cert) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/ant/ssl/configuration.rb', line 33 def configure_cert_details!(cert) cert.version = 2 cert.serial = @config['serial'] cert.subject = OpenSSL::X509::Name.parse(subject_string) cert.not_before = Time.now cert.not_after = cert.not_before + ONE_YEAR * @config['expiration'] end |
#configure_extensions!(cert, extension_factory) ⇒ Object
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/ant/ssl/configuration.rb', line 41 def configure_extensions!(cert, extension_factory) @config['extensions'].each do |name, details| extension = extension_factory.create_extension( name, details['details'], details['critical'] ) cert.add_extension(extension) end end |
#crt_path ⇒ Object
19 20 21 |
# File 'lib/ant/ssl/configuration.rb', line 19 def crt_path saving_directory('crt') end |
#key_path ⇒ Object
23 24 25 |
# File 'lib/ant/ssl/configuration.rb', line 23 def key_path saving_directory('key') end |
#saving_directory(type) ⇒ Object
13 14 15 16 17 |
# File 'lib/ant/ssl/configuration.rb', line 13 def saving_directory(type) path = @config['saving_directory'] serial = @config['serial'] "#{path}/#{serial}.#{type}.pem" end |
#subject_string ⇒ Object
27 28 29 30 31 |
# File 'lib/ant/ssl/configuration.rb', line 27 def subject_string "/C=#{@config['country']}/ST=#{@config['state']}" \ "/L=#{@config['city']}/O=#{@config['organization']}" \ "/OU=#{@config['team']}/CN=#{@config['name']}" end |