mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-06-19 14:14:11 -04:00
ACME Reprovisioning (#4522)
This commit is contained in:
parent
4ffd10f46d
commit
6e2a5aa050
5 changed files with 89 additions and 25 deletions
|
@ -64,10 +64,14 @@ class TlsConfig(Config):
|
|||
self.tls_certificate = None
|
||||
self.tls_private_key = None
|
||||
|
||||
def is_disk_cert_valid(self):
|
||||
def is_disk_cert_valid(self, allow_self_signed=True):
|
||||
"""
|
||||
Is the certificate we have on disk valid, and if so, for how long?
|
||||
|
||||
Args:
|
||||
allow_self_signed (bool): Should we allow the certificate we
|
||||
read to be self signed?
|
||||
|
||||
Returns:
|
||||
int: Days remaining of certificate validity.
|
||||
None: No certificate exists.
|
||||
|
@ -88,6 +92,12 @@ class TlsConfig(Config):
|
|||
logger.exception("Failed to parse existing certificate off disk!")
|
||||
raise
|
||||
|
||||
if not allow_self_signed:
|
||||
if tls_certificate.get_subject() == tls_certificate.get_issuer():
|
||||
raise ValueError(
|
||||
"TLS Certificate is self signed, and this is not permitted"
|
||||
)
|
||||
|
||||
# YYYYMMDDhhmmssZ -- in UTC
|
||||
expires_on = datetime.strptime(
|
||||
tls_certificate.get_notAfter().decode('ascii'), "%Y%m%d%H%M%SZ"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue