Class: Acmesmith::SaveCertificateService
- Inherits:
-
Object
- Object
- Acmesmith::SaveCertificateService
- Defined in:
- lib/acmesmith/save_certificate_service.rb
Instance Attribute Summary collapse
-
#cert ⇒ Object
readonly
Returns the value of attribute cert.
-
#certificate_file ⇒ Object
readonly
Returns the value of attribute certificate_file.
-
#certificate_mode ⇒ Object
readonly
Returns the value of attribute certificate_mode.
-
#chain_file ⇒ Object
readonly
Returns the value of attribute chain_file.
-
#fullchain_file ⇒ Object
readonly
Returns the value of attribute fullchain_file.
-
#key_file ⇒ Object
readonly
Returns the value of attribute key_file.
-
#key_mode ⇒ Object
readonly
Returns the value of attribute key_mode.
-
#version_file ⇒ Object
readonly
Returns the value of attribute version_file.
Instance Method Summary collapse
- #atomic? ⇒ Boolean
-
#initialize(cert, key_mode: '0600', certificate_mode: '0644', version_file: nil, key_file: nil, fullchain_file: nil, chain_file: nil, certificate_file: nil, atomic: true, verbose: false) ⇒ SaveCertificateService
constructor
A new instance of SaveCertificateService.
- #local_version ⇒ Object
- #perform! ⇒ Object
Constructor Details
permalink #initialize(cert, key_mode: '0600', certificate_mode: '0644', version_file: nil, key_file: nil, fullchain_file: nil, chain_file: nil, certificate_file: nil, atomic: true, verbose: false) ⇒ SaveCertificateService
Returns a new instance of SaveCertificateService.
3 4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/acmesmith/save_certificate_service.rb', line 3 def initialize(cert, key_mode: '0600', certificate_mode: '0644', version_file: nil, key_file: nil, fullchain_file: nil, chain_file: nil, certificate_file: nil, atomic: true, verbose: false) @cert = cert @key_mode = key_mode @certificate_mode = certificate_mode @version_file = version_file @key_file = key_file @fullchain_file = fullchain_file @chain_file = chain_file @certificate_file = certificate_file @atomic = atomic @verbose = verbose end |
Instance Attribute Details
permalink #cert ⇒ Object (readonly)
Returns the value of attribute cert.
16 17 18 |
# File 'lib/acmesmith/save_certificate_service.rb', line 16 def cert @cert end |
permalink #certificate_file ⇒ Object (readonly)
Returns the value of attribute certificate_file.
18 19 20 |
# File 'lib/acmesmith/save_certificate_service.rb', line 18 def certificate_file @certificate_file end |
permalink #certificate_mode ⇒ Object (readonly)
Returns the value of attribute certificate_mode.
17 18 19 |
# File 'lib/acmesmith/save_certificate_service.rb', line 17 def certificate_mode @certificate_mode end |
permalink #chain_file ⇒ Object (readonly)
Returns the value of attribute chain_file.
18 19 20 |
# File 'lib/acmesmith/save_certificate_service.rb', line 18 def chain_file @chain_file end |
permalink #fullchain_file ⇒ Object (readonly)
Returns the value of attribute fullchain_file.
18 19 20 |
# File 'lib/acmesmith/save_certificate_service.rb', line 18 def fullchain_file @fullchain_file end |
permalink #key_file ⇒ Object (readonly)
Returns the value of attribute key_file.
18 19 20 |
# File 'lib/acmesmith/save_certificate_service.rb', line 18 def key_file @key_file end |
permalink #key_mode ⇒ Object (readonly)
Returns the value of attribute key_mode.
17 18 19 |
# File 'lib/acmesmith/save_certificate_service.rb', line 17 def key_mode @key_mode end |
permalink #version_file ⇒ Object (readonly)
Returns the value of attribute version_file.
18 19 20 |
# File 'lib/acmesmith/save_certificate_service.rb', line 18 def version_file @version_file end |
Instance Method Details
permalink #atomic? ⇒ Boolean
19 |
# File 'lib/acmesmith/save_certificate_service.rb', line 19 def atomic?; !!@atomic; end |
permalink #local_version ⇒ Object
[View source]
35 36 37 38 39 40 41 42 43 |
# File 'lib/acmesmith/save_certificate_service.rb', line 35 def local_version @local_version ||= begin if version_file && File.exist?(version_file) File.read(version_file).chomp else nil end end end |
permalink #perform! ⇒ Object
[View source]
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/acmesmith/save_certificate_service.rb', line 21 def perform! if local_version == cert.version return end log "Saving certificate CN=#{cert.common_name} (ver: #{cert.version})" write_file(key_file, key_mode, cert.private_key) write_file(certificate_file, certificate_mode, cert.certificate.to_pem) write_file(chain_file, certificate_mode, cert.chain) write_file(fullchain_file, certificate_mode, cert.fullchain) write_file(version_file, certificate_mode, cert.version) end |