diff --git a/README.md b/README.md index 7375a4b..c685261 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,7 @@ mode: webdir #mode: standalone #port: 13135 webdir: /var/www/acme-challenge/ +cafile: /etc/acme/letencrypt_ca.crt defaults: format: crt diff --git a/acertmgr.py b/acertmgr.py index 1931221..b132daa 100755 --- a/acertmgr.py +++ b/acertmgr.py @@ -165,6 +165,7 @@ def cert_get(domain, settings): # @return the action to be executed after the certificate update def cert_put(domain, settings): # TODO error handling + ca_file = settings.get("cafile", "") crt_user = settings['user'] crt_group = settings['group'] crt_perm = settings['perm'] @@ -185,7 +186,12 @@ def cert_put(domain, settings): src_fd = open(key_file, "r") crt_fd.write(src_fd.read()) src_fd.close() - # TODO fmt == "ca": + if fmt == "ca": + if not os.path.isfile(ca_file): + raise FileNotFoundError("The server key file (%s) is missing!" % ca_file) + src_fd = open(ca_file, "r") + crt_fd.write(src_fd.read()) + src_fd.close() else: # TODO error handling pass