diff --git a/locales/en.json b/locales/en.json index 10dc41edb..85b25efe9 100644 --- a/locales/en.json +++ b/locales/en.json @@ -251,5 +251,7 @@ "certmanager_cert_install_success_selfsigned" : "Successfully installed a self-signed certificate for domain {domain:s} !", "certmanager_cert_install_success" : "Successfully installed Let's Encrypt certificate for domain {domain:s} !", "certmanager_cert_renew_success" : "Successfully renewed Let's Encrypt certificate for domain {domain:s} !", - "certmanager_old_letsencrypt_app_detected" : "\nYunohost detected that the 'letsencrypt' app is installed, which conflits with the new built-in certificate management features in Yunohost. If you wish to use the new built-in features, please run the following commands to migrate your installation :\n\n yunohost app remove letsencrypt\n yunohost domain cert-install\n\nN.B. : this will attempt to re-install certificates for all domains with a Let's Encrypt certificate or self-signed certificate." + "certmanager_old_letsencrypt_app_detected" : "\nYunohost detected that the 'letsencrypt' app is installed, which conflits with the new built-in certificate management features in Yunohost. If you wish to use the new built-in features, please run the following commands to migrate your installation :\n\n yunohost app remove letsencrypt\n yunohost domain cert-install\n\nN.B. : this will attempt to re-install certificates for all domains with a Let's Encrypt certificate or self-signed certificate.", + "certmanager_hit_rate_limit" :"Too many certificates already issued for exact set of domains {domain:s} recently. Please try again later. See https://letsencrypt.org/docs/rate-limits/ for more details.", + "certmanager_cert_signing_failed" : "Signing the new certificate failed." } diff --git a/src/yunohost/certificate.py b/src/yunohost/certificate.py index ec733f657..99e6bd014 100644 --- a/src/yunohost/certificate.py +++ b/src/yunohost/certificate.py @@ -31,7 +31,6 @@ import grp import smtplib import requests import subprocess - import dns.resolver from OpenSSL import crypto @@ -470,11 +469,20 @@ def _fetch_and_enable_new_certificate(domain): domain_csr_file = "%s/%s.csr" % (TMP_FOLDER, domain) - signed_certificate = sign_certificate(ACCOUNT_KEY_FILE, - domain_csr_file, - WEBROOT_FOLDER, - log=logger, - CA=CERTIFICATION_AUTHORITY) + try: + signed_certificate = sign_certificate(ACCOUNT_KEY_FILE, + domain_csr_file, + WEBROOT_FOLDER, + log=logger, + CA=CERTIFICATION_AUTHORITY) + except ValueError as e: + if ("urn:acme:error:rateLimited" in str(e)) : + raise MoulinetteError(errno.EINVAL, m18n.n('certmanager_hit_rate_limit', domain=domain)) + else : + raise + except Exception as e: + raise MoulinetteError(errno.EINVAL, m18n.n('certmanager_cert_signing_failed')) + logger.error(str(e)) intermediate_certificate = requests.get(INTERMEDIATE_CERTIFICATE_URL).text @@ -612,10 +620,10 @@ def _get_status(domain): "verbose": "Unknown?", } - try : + try: _check_domain_is_ready_for_ACME(domain) ACME_eligible = True - except : + except: ACME_eligible = False return {