Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit 4d6d38a

Browse files
authored
Remove dead code from acme support. (#11393)
1 parent 5505da2 commit 4d6d38a

File tree

2 files changed

+1
-50
lines changed

2 files changed

+1
-50
lines changed

changelog.d/11393.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Remove dead code from supporting ACME.

synapse/config/tls.py

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
import logging
1616
import os
17-
from datetime import datetime
1817
from typing import List, Optional, Pattern
1918

2019
from OpenSSL import SSL, crypto
@@ -133,55 +132,6 @@ def read_config(self, config: dict, config_dir_path: str, **kwargs):
133132
self.tls_certificate: Optional[crypto.X509] = None
134133
self.tls_private_key: Optional[crypto.PKey] = None
135134

136-
def is_disk_cert_valid(self, allow_self_signed=True):
137-
"""
138-
Is the certificate we have on disk valid, and if so, for how long?
139-
140-
Args:
141-
allow_self_signed (bool): Should we allow the certificate we
142-
read to be self signed?
143-
144-
Returns:
145-
int: Days remaining of certificate validity.
146-
None: No certificate exists.
147-
"""
148-
if not os.path.exists(self.tls_certificate_file):
149-
return None
150-
151-
try:
152-
with open(self.tls_certificate_file, "rb") as f:
153-
cert_pem = f.read()
154-
except Exception as e:
155-
raise ConfigError(
156-
"Failed to read existing certificate file %s: %s"
157-
% (self.tls_certificate_file, e)
158-
)
159-
160-
try:
161-
tls_certificate = crypto.load_certificate(crypto.FILETYPE_PEM, cert_pem)
162-
except Exception as e:
163-
raise ConfigError(
164-
"Failed to parse existing certificate file %s: %s"
165-
% (self.tls_certificate_file, e)
166-
)
167-
168-
if not allow_self_signed:
169-
if tls_certificate.get_subject() == tls_certificate.get_issuer():
170-
raise ValueError(
171-
"TLS Certificate is self signed, and this is not permitted"
172-
)
173-
174-
# YYYYMMDDhhmmssZ -- in UTC
175-
expiry_data = tls_certificate.get_notAfter()
176-
if expiry_data is None:
177-
raise ValueError(
178-
"TLS Certificate has no expiry date, and this is not permitted"
179-
)
180-
expires_on = datetime.strptime(expiry_data.decode("ascii"), "%Y%m%d%H%M%SZ")
181-
now = datetime.utcnow()
182-
days_remaining = (expires_on - now).days
183-
return days_remaining
184-
185135
def read_certificate_from_disk(self):
186136
"""
187137
Read the certificates and private key from disk.

0 commit comments

Comments
 (0)