mirror of
https://github.com/element-hq/synapse.git
synced 2024-12-22 12:44:30 +03:00
Simplify with better exception handling
This commit is contained in:
parent
1fd5680496
commit
7c432de63e
1 changed files with 4 additions and 9 deletions
|
@ -96,20 +96,15 @@ class TlsConfig(Config):
|
||||||
certs = []
|
certs = []
|
||||||
for ca_file in self.federation_custom_ca_list:
|
for ca_file in self.federation_custom_ca_list:
|
||||||
logger.debug("Reading custom CA certificate file: %s", ca_file)
|
logger.debug("Reading custom CA certificate file: %s", ca_file)
|
||||||
try:
|
content = self.read_file(ca_file)
|
||||||
with open(ca_file, 'rb') as f:
|
|
||||||
content = f.read()
|
|
||||||
except Exception:
|
|
||||||
logger.fatal("Failed to read custom CA certificate off disk")
|
|
||||||
raise
|
|
||||||
|
|
||||||
# Parse the CA certificates
|
# Parse the CA certificates
|
||||||
try:
|
try:
|
||||||
cert_base = Certificate.loadPEM(content)
|
cert_base = Certificate.loadPEM(content)
|
||||||
certs.append(cert_base)
|
certs.append(cert_base)
|
||||||
except Exception:
|
except Exception as e:
|
||||||
logger.fatal("Failed to parse custom CA certificate off disk")
|
raise ConfigError("Error parsing custom CA certificate file %s: %s"
|
||||||
raise
|
% (ca_file, e))
|
||||||
|
|
||||||
self.federation_custom_ca_list = trustRootFromCertificates(certs)
|
self.federation_custom_ca_list = trustRootFromCertificates(certs)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue