class LetsencryptWebfaction::CertificateInstaller

Public Class Methods

new(cert_name, certificate, private_key, credentials) click to toggle source
# File lib/letsencrypt_webfaction/certificate_installer.rb, line 7
def initialize(cert_name, certificate, private_key, credentials)
  @cert_name = cert_name
  @certificate = certificate
  @private_key = private_key
  @credentials = credentials
end

Public Instance Methods

install!() click to toggle source
# File lib/letsencrypt_webfaction/certificate_installer.rb, line 14
def install!
  cert_list = @credentials.call('list_certificates')
  action = if cert_list.find { |cert| cert['name'] == @cert_name }
             'update_certificate'
           else
             'create_certificate'
           end
  @credentials.call(action, @cert_name, @certificate, @private_key.to_pem)

  true
end