Fix maximum TTL calculation on records
This commit is contained in:
parent
b558f1ca4d
commit
ca5263f386
|
@ -194,11 +194,10 @@ class RenewHandler(HandlerBase):
|
|||
for renewal hooks to run.
|
||||
"""
|
||||
cert_config = self._config.runtime.adopted[certconfig_path]
|
||||
ttl = max(
|
||||
(x.ttl for x in cert_config.hosts if isinstance(x.ttl, int)),
|
||||
default=self._config.defaults.tlsa.ttl)
|
||||
if cert_config.max_ttl == 0:
|
||||
cert_config.max_ttl = self._config.defaults.tlsa.ttl
|
||||
utcnow = datetime.now(tz=timezone.utc).timestamp()
|
||||
if cert.latest_upcoming_mtime + ttl > utcnow:
|
||||
if cert.latest_upcoming_mtime + cert_config.max_ttl > utcnow:
|
||||
# No putting in place necessary yet
|
||||
return []
|
||||
cert.set_upcoming_as_latest()
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from abc import ABCMeta
|
||||
from collections.abc import Generator
|
||||
from dataclasses import dataclass
|
||||
from functools import cached_property
|
||||
from io import TextIOWrapper
|
||||
|
@ -465,6 +466,16 @@ class AdoptedCertConfig(object):
|
|||
result['hosts'] = [x.dump() for x in self.hosts]
|
||||
return result
|
||||
|
||||
@cached_property
|
||||
def max_ttl(self) -> int:
|
||||
'Return the biggest TTL in the records or `0` if there is none.'
|
||||
result = set([0])
|
||||
for host in self.hosts or []:
|
||||
for record in host.records or []:
|
||||
if isinstance(record.ttl, int):
|
||||
result.add(record.ttl)
|
||||
return max(result)
|
||||
|
||||
|
||||
@dataclass
|
||||
class _RuntimeConfiguration(object):
|
||||
|
|
Loading…
Reference in New Issue