diff options
author | Andrew Morgan <andrew@amorgan.xyz> | 2019-04-03 10:58:50 +0100 |
---|---|---|
committer | Andrew Morgan <andrew@amorgan.xyz> | 2019-04-03 10:58:50 +0100 |
commit | 7c432de63e0cdf575ceff352ece45fe7606356d7 (patch) | |
tree | f0cf957f4af6f261857682e6b27193e433264a63 /synapse/config/tls.py | |
parent | Don't laugh at my own jokes (diff) | |
download | synapse-7c432de63e0cdf575ceff352ece45fe7606356d7.tar.xz |
Simplify with better exception handling
Diffstat (limited to '')
-rw-r--r-- | synapse/config/tls.py | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/synapse/config/tls.py b/synapse/config/tls.py index dbfeb236e4..2022da5147 100644 --- a/synapse/config/tls.py +++ b/synapse/config/tls.py @@ -96,20 +96,15 @@ class TlsConfig(Config): certs = [] for ca_file in self.federation_custom_ca_list: logger.debug("Reading custom CA certificate file: %s", ca_file) - try: - with open(ca_file, 'rb') as f: - content = f.read() - except Exception: - logger.fatal("Failed to read custom CA certificate off disk") - raise + content = self.read_file(ca_file) # Parse the CA certificates try: cert_base = Certificate.loadPEM(content) certs.append(cert_base) - except Exception: - logger.fatal("Failed to parse custom CA certificate off disk") - raise + except Exception as e: + raise ConfigError("Error parsing custom CA certificate file %s: %s" + % (ca_file, e)) self.federation_custom_ca_list = trustRootFromCertificates(certs) |