class LetsencryptWebfaction::CertificateIssuer
Public Class Methods
new(certificate:, api_credentials:, client:)
click to toggle source
# File lib/letsencrypt_webfaction/certificate_issuer.rb, line 9 def initialize(certificate:, api_credentials:, client:) @cert_config = certificate @api_credentials = api_credentials @client = client end
Public Instance Methods
call()
click to toggle source
# File lib/letsencrypt_webfaction/certificate_issuer.rb, line 15 def call # Validate the domains. return unless validator.validate! # Write the obtained certificates. certificate_installer.install! output_success_help end
Private Instance Methods
certificate()
click to toggle source
# File lib/letsencrypt_webfaction/certificate_issuer.rb, line 39 def certificate # We can now request a certificate, you can pass anything that returns # a valid DER encoded CSR when calling to_der on it, for example a # OpenSSL::X509::Request too. @_certificate ||= begin order.finalize(csr: csr) while order.status == 'processing' sleep(2) order.reload end order.certificate end end
certificate_installer()
click to toggle source
# File lib/letsencrypt_webfaction/certificate_issuer.rb, line 35 def certificate_installer @_certificate_installer ||= LetsencryptWebfaction::CertificateInstaller.new(@cert_config.cert_name, certificate, csr.private_key, @api_credentials) end
csr()
click to toggle source
# File lib/letsencrypt_webfaction/certificate_issuer.rb, line 54 def csr # We're going to need a certificate signing request. If not explicitly # specified, the first name listed becomes the common name. @_csr ||= Acme::Client::CertificateRequest.new(names: @cert_config.domains) end
order()
click to toggle source
# File lib/letsencrypt_webfaction/certificate_issuer.rb, line 27 def order @_order ||= @client.new_order(identifiers: @cert_config.domains) end
output_success_help()
click to toggle source
# File lib/letsencrypt_webfaction/certificate_issuer.rb, line 60 def output_success_help Out.puts 'Your new certificate is now created and installed.' Out.puts "You will need to change your application to use the #{@cert_config.cert_name} certificate." Out.puts 'Add the `--quiet` parameter in your cron task to remove this message.' end
validator()
click to toggle source
# File lib/letsencrypt_webfaction/certificate_issuer.rb, line 31 def validator @_validator ||= LetsencryptWebfaction::DomainValidator.new order, @client, @cert_config.public_dirs end