5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/apartment_acme_client/renewal_service.rb', line 5
def self.run!
good_domains, rejected_domains = ApartmentAcmeClient::DomainChecker.new.accessible_domains
puts "All domains to be requested: #{good_domains}, invalid domains: #{rejected_domains}"
common_name = ApartmentAcmeClient.common_name || good_domains.first
encryptor = ApartmentAcmeClient::Encryption.new
certificate = encryptor.request_certificate(
common_name: common_name,
domains: good_domains,
wildcard_domain: ApartmentAcmeClient.wildcard_domain
)
if certificate.nil?
puts "ERROR, no certificate returned aborting"
return
end
ApartmentAcmeClient::CertificateStorage::Proxy.singleton.store_certificate_string(certificate)
ApartmentAcmeClient::CertificateStorage::Proxy.singleton.store_csr_private_key_string(encryptor.csr_private_key_string)
puts 'Restarting nginx with new certificate'
ApartmentAcmeClient::FileManipulation::Proxy.singleton.restart_service('nginx')
puts 'done.'
end
|