Add checks for errors during certificate creation

This commit is contained in:
David Klaftenegger 2016-01-11 21:38:09 +01:00 committed by Markus Hauschild
parent d2a47fbd6a
commit a614df5d3a
1 changed files with 9 additions and 5 deletions

View File

@ -80,12 +80,16 @@ def cert_get(domain, settings):
raise FileExistsError("A temporary file already exists!")
cr = subprocess.check_output(['openssl', 'req', '-new', '-sha256', '-key', key_file, '-out', csr_file, '-subj', '/CN=%s' % domain])
try:
cr = subprocess.check_output(['openssl', 'req', '-new', '-sha256', '-key', key_file, '-out', csr_file, '-subj', '/CN=%s' % domain])
# get certificate
crt = acme_tiny.get_crt(acc_file, csr_file, CHALLENGE_DIR, CA = LE_CA)
with open(crt_file, "w") as crt_fd:
crt_fd.write(crt)
# get certificate
crt = acme_tiny.get_crt(acc_file, csr_file, CHALLENGE_DIR, CA = LE_CA)
with open(crt_file, "w") as crt_fd:
crt_fd.write(crt)
except Exception:
os.remove(csr_file)
raise
# TODO check if resulting certificate is valid