From 208cb4017f20cd889997bdfd0bb319eab44ca6fe Mon Sep 17 00:00:00 2001 From: "Robin C. Ladiges" Date: Fri, 25 Jun 2021 05:50:04 +0200 Subject: acmens.py: refac if/else --- acmens.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/acmens.py b/acmens.py index 37e187f..eb0ec9a 100644 --- a/acmens.py +++ b/acmens.py @@ -155,18 +155,17 @@ def _do_challenge(challenge_type, authz_url, nonce_url, auth, account_key, thumb if c["type"] == "http-01": http_challenge = c if challenge is None: - if http_challenge is None: - if dns_challenge is None: - sys.stderr.write("Error: Unable to find challenges!") - sys.exit(1) - else: - # Fallback to dns challenge. - challenge = dns_challenge - challenge_type = "dns" - else: + if http_challenge: # Fallback to http challenge. challenge = http_challenge challenge_type = "http" + elif dns_challenge: + # Fallback to dns challenge. + challenge = dns_challenge + challenge_type = "dns" + else: + sys.stderr.write("Error: Unable to find challenges!") + sys.exit(1) keyauthorization = "{0}.{1}".format(challenge["token"], thumbprint) dns_payload = _b64(hashlib.sha256(keyauthorization.encode()).digest()) -- cgit v1.2.3