Commit bcda00ea authored by Adrien Dorsaz's avatar Adrien Dorsaz

acme_dns_tiny: replace finalize by order variable to reflect the object getted

That's make even more sense as there's no "finalize" object, but just a "finalize" URL.
parent 95443c29
...@@ -239,8 +239,6 @@ def get_crt(config, log=LOGGER): ...@@ -239,8 +239,6 @@ def get_crt(config, log=LOGGER):
_update_dns(dnsrr_set, "delete") _update_dns(dnsrr_set, "delete")
log.info("Request to finalize the order (all chalenge have been completed)") log.info("Request to finalize the order (all chalenge have been completed)")
resp = requests.get(order_location, headers=adtheaders)
finalize = resp.json()
csr_der = _b64(_openssl("req", ["-in", config["acmednstiny"]["CSRFile"], "-outform", "DER"])) csr_der = _b64(_openssl("req", ["-in", config["acmednstiny"]["CSRFile"], "-outform", "DER"]))
code, result, headers = _send_signed_request(order["finalize"], {"csr": csr_der}) code, result, headers = _send_signed_request(order["finalize"], {"csr": csr_der})
if code != 200: if code != 200:
...@@ -250,30 +248,30 @@ def get_crt(config, log=LOGGER): ...@@ -250,30 +248,30 @@ def get_crt(config, log=LOGGER):
try: try:
resp = requests.get(order_location, headers=adtheaders) resp = requests.get(order_location, headers=adtheaders)
resp.raise_for_status() resp.raise_for_status()
finalize = resp.json() order = resp.json()
except requests.exceptions.RequestException as error: except requests.exceptions.RequestException as error:
raise ValueError("Error finalizing order: {0} {1}".format( raise ValueError("Error finalizing order: {0} {1}".format(
error.response.status_code, error.response.text())) error.response.status_code, error.response.text()))
if finalize["status"] == "processing": if order["status"] == "processing":
if resp.headers["Retry-After"]: if resp.headers["Retry-After"]:
time.sleep(resp.headers["Retry-After"]) time.sleep(resp.headers["Retry-After"])
else: else:
time.sleep(2) time.sleep(2)
elif finalize["status"] == "valid": elif order["status"] == "valid":
log.info("Order finalized!") log.info("Order finalized!")
break break
else: else:
raise ValueError("Finalizing order {0} got errors: {1}".format( raise ValueError("Finalizing order {0} got errors: {1}".format(
domain, finalize)) domain, order))
resp = requests.get(finalize["certificate"], headers=adtheaders) resp = requests.get(order["certificate"], headers=adtheaders)
if resp.status_code != 200: if resp.status_code != 200:
raise ValueError("Finalizing order {0} got errors: {1}".format( raise ValueError("Finalizing order {0} got errors: {1}".format(
resp.status_code, resp.json())) resp.status_code, resp.json()))
certchain = resp.text certchain = resp.text
log.info("Certificate signed and chain received: {0}".format(finalize["certificate"])) log.info("Certificate signed and chain received: {0}".format(order["certificate"]))
return certchain return certchain
def main(argv): def main(argv):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment