diff --git a/locales/en.json b/locales/en.json index 806def22a..7de00f395 100644 --- a/locales/en.json +++ b/locales/en.json @@ -256,5 +256,6 @@ "certmanager_cert_signing_failed" : "Signing the new certificate failed.", "certmanager_no_cert_file" : "Unable to read certificate file for domain {domain:s} (file : {file:s})", "certmanager_conflicting_nginx_file": "Unable to prepare domain for ACME challenge : the nginx configuration file {filepath:s} is conflicting and should be removed first.", - "certmanager_unable_to_determine_self_CA_name": "Unable to determine name of self-signing authority." + "certmanager_self_ca_conf_file_not_found" : "Configuration file not found for self-signing CA ({file:s})", + "certmanager_unable_to_parse_self_CA_name": "Unable to parse name of self-signing authority in {file:s}." } diff --git a/src/yunohost/certificate.py b/src/yunohost/certificate.py index 74e93314c..8209160a4 100644 --- a/src/yunohost/certificate.py +++ b/src/yunohost/certificate.py @@ -812,17 +812,18 @@ def _domain_is_accessible_through_HTTP(ip, domain): def _name_self_CA(): ca_conf = os.path.join(SSL_DIR, "openssl.ca.cnf") - try : - with open(ca_conf) as f: - lines = f.readlines() + if not os.path.exists(ca_conf) : + logger.warning(m18n.n('certmanager_self_ca_conf_file_not_found', file=ca_conf)) + return "" - for line in lines: - if line.startswith("commonName_default"): - return line.split()[2] - except: - pass + with open(ca_conf) as f: + lines = f.readlines() - logger.warning(m18n.n('certmanager_unable_to_determine_self_CA_name')) + for line in lines: + if line.startswith("commonName_default"): + return line.split()[2] + + logger.warning(m18n.n('certmanager_unable_to_parse_self_CA_name', file=ca_conf)) return ""