Class: Puma::Acme::Cert
- Inherits:
-
Struct
- Object
- Struct
- Puma::Acme::Cert
- Defined in:
- lib/puma/acme/structs.rb
Instance Attribute Summary collapse
-
#algorithm ⇒ Object
Returns the value of attribute algorithm.
-
#cert_pem ⇒ Object
Returns the value of attribute cert_pem.
-
#identifiers ⇒ Object
Returns the value of attribute identifiers.
-
#key_pem ⇒ Object
Returns the value of attribute key_pem.
-
#order ⇒ Object
Returns the value of attribute order.
Class Method Summary collapse
Instance Method Summary collapse
- #expired?(now: Time.now.utc) ⇒ Boolean
-
#initialize(identifiers: nil, **kwargs) ⇒ Cert
constructor
A new instance of Cert.
- #key ⇒ Object
- #names ⇒ Object
- #renewable?(renew_in, now: Time.now.utc) ⇒ Boolean
- #usable?(now: Time.now.utc) ⇒ Boolean
Constructor Details
#initialize(identifiers: nil, **kwargs) ⇒ Cert
Returns a new instance of Cert.
56 57 58 59 60 |
# File 'lib/puma/acme/structs.rb', line 56 def initialize(identifiers: nil, **kwargs) identifiers = identifiers&.map { |value| Identifier.parse(value) } super(identifiers: identifiers, **kwargs) end |
Instance Attribute Details
#algorithm ⇒ Object
Returns the value of attribute algorithm
51 52 53 |
# File 'lib/puma/acme/structs.rb', line 51 def algorithm @algorithm end |
#cert_pem ⇒ Object
Returns the value of attribute cert_pem
51 52 53 |
# File 'lib/puma/acme/structs.rb', line 51 def cert_pem @cert_pem end |
#identifiers ⇒ Object
Returns the value of attribute identifiers
51 52 53 |
# File 'lib/puma/acme/structs.rb', line 51 def identifiers @identifiers end |
#key_pem ⇒ Object
Returns the value of attribute key_pem
51 52 53 |
# File 'lib/puma/acme/structs.rb', line 51 def key_pem @key_pem end |
#order ⇒ Object
Returns the value of attribute order
51 52 53 |
# File 'lib/puma/acme/structs.rb', line 51 def order @order end |
Class Method Details
.key(algorithm:, identifiers:) ⇒ Object
52 53 54 |
# File 'lib/puma/acme/structs.rb', line 52 def self.key(algorithm:, identifiers:) new(algorithm: algorithm, identifiers: identifiers).key end |
Instance Method Details
#expired?(now: Time.now.utc) ⇒ Boolean
77 78 79 |
# File 'lib/puma/acme/structs.rb', line 77 def expired?(now: Time.now.utc) x509.not_after < now end |
#key ⇒ Object
69 70 71 |
# File 'lib/puma/acme/structs.rb', line 69 def key [:cert, algorithm, identifiers&.map(&:key)] end |
#names ⇒ Object
73 74 75 |
# File 'lib/puma/acme/structs.rb', line 73 def names identifiers&.map(&:value) end |
#renewable?(renew_in, now: Time.now.utc) ⇒ Boolean
85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/puma/acme/structs.rb', line 85 def renewable?(renew_in, now: Time.now.utc) case renew_in when Float renew_at = x509.not_before + (x509.not_after - x509.not_before) * renew_in when Integer renew_at = x509.not_before + renew_in else raise UnknownRenewIn, renew_in end now >= renew_at end |
#usable?(now: Time.now.utc) ⇒ Boolean
81 82 83 |
# File 'lib/puma/acme/structs.rb', line 81 def usable?(now: Time.now.utc) !cert_pem.nil? && !key_pem.nil? && !expired?(now: now) end |