Sha256: 25e09acc2f95d86d4da6a60d29cdd9067f64df3108c875e7484dfb13a9826670

Contents?: true

Size: 698 Bytes

Versions: 6

Compression:

Stored size: 698 Bytes

Contents

require 'xmlrpc/client'

module LetsencryptWebfaction
  class CertificateInstaller
    WEBFACTION_API_VERSION = 2

    def initialize(cert_name, certificate, credentials)
      @cert_name = cert_name
      @certificate = certificate
      @credentials = credentials
    end

    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.to_pem, @certificate.request.private_key.to_pem, @certificate.chain_to_pem)

      true
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
letsencrypt_webfaction-2.2.3 lib/letsencrypt_webfaction/certificate_installer.rb
letsencrypt_webfaction-2.2.2 lib/letsencrypt_webfaction/certificate_installer.rb
letsencrypt_webfaction-2.2.1 lib/letsencrypt_webfaction/certificate_installer.rb
letsencrypt_webfaction-2.2.0 lib/letsencrypt_webfaction/certificate_installer.rb
letsencrypt_webfaction-2.1.0 lib/letsencrypt_webfaction/certificate_installer.rb
letsencrypt_webfaction-2.0.1 lib/letsencrypt_webfaction/certificate_installer.rb