Class: AcmeManager::Certificate

Inherits:
Object
  • Object
show all
Defined in:
lib/acme_manager/certificate.rb

Overview

Represents a certificaate managed by acme-manager

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, not_after) ⇒ Certificate

Returns a new instance of Certificate.

Parameters:

  • name (String)

    Domain name the certificate relates to

  • not_after (Time)

    Timestamp representing the expiry time of the certificate



8
9
10
11
# File 'lib/acme_manager/certificate.rb', line 8

def initialize(name, not_after)
  self.name = name
  self.not_after = not_after
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/acme_manager/certificate.rb', line 4

def name
  @name
end

#not_afterObject

Returns the value of attribute not_after.



4
5
6
# File 'lib/acme_manager/certificate.rb', line 4

def not_after
  @not_after
end

Class Method Details

.allArray<Certificate>

Fetch a list of all certificates that acme-manager is currently managing

Returns:

  • (Array<Certificate>)

    All currently managed certificates



21
22
23
24
25
26
# File 'lib/acme_manager/certificate.rb', line 21

def self.all
  Request.make('list').map do |cert_info|
    AcmeManager.logger.info "Requesting list of certificates"
    new(cert_info['name'], Time.iso8601(cert_info['not_after']))
  end
end

Instance Method Details

#expired?Boolean

Certificate is expired when we’re past it’s expiry time

Returns:

  • (Boolean)


14
15
16
# File 'lib/acme_manager/certificate.rb', line 14

def expired?
  Time.now.utc > not_after
end