|
14 | 14 | import sys |
15 | 15 | import signal |
16 | 16 | import threading |
17 | | -import time |
18 | | - |
19 | 17 | from cryptography.hazmat.backends import default_backend |
20 | 18 | from cryptography.hazmat.primitives.asymmetric import rsa |
21 | 19 | from cryptography import x509 |
@@ -55,11 +53,11 @@ def make_client(email=None): |
55 | 53 | """Build an acme.Client and register a new account with a random key.""" |
56 | 54 | client = uninitialized_client() |
57 | 55 | tos = client.directory.meta.terms_of_service |
58 | | - if tos == ACCEPTABLE_TOS: |
59 | | - client.net.account = client.new_account(messages.NewRegistration.from_data(email=email, |
60 | | - terms_of_service_agreed=True)) |
61 | | - else: |
| 56 | + if tos != ACCEPTABLE_TOS: |
62 | 57 | raise Exception("Unrecognized terms of service URL %s" % tos) |
| 58 | + |
| 59 | + client.net.account = client.new_account(messages.NewRegistration.from_data(email=email, |
| 60 | + terms_of_service_agreed=True)) |
63 | 61 | return client |
64 | 62 |
|
65 | 63 | class NoClientError(ValueError): |
@@ -140,21 +138,13 @@ def auth_and_issue(domains, chall_type="dns-01", email=None, cert_output=None, c |
140 | 138 | else: |
141 | 139 | raise Exception("invalid challenge type %s" % chall_type) |
142 | 140 |
|
143 | | - # Make up to three attempts, retrying on badNonce errors |
144 | | - for n in range(3): |
145 | | - time.sleep(0.2 * n) # No sleep before the first attempt, then backoff |
146 | | - try: |
147 | | - order = client.poll_and_finalize(order) |
148 | | - if cert_output is not None: |
149 | | - with open(cert_output, "w") as f: |
150 | | - f.write(order.fullchain_pem) |
151 | | - except messages.Error as e: |
152 | | - if e.typ == "urn:ietf:params:acme:error:badNonce": |
153 | | - continue |
154 | | - else: |
155 | | - break |
156 | | - finally: |
157 | | - cleanup() |
| 141 | + try: |
| 142 | + order = client.poll_and_finalize(order) |
| 143 | + if cert_output is not None: |
| 144 | + with open(cert_output, "w") as f: |
| 145 | + f.write(order.fullchain_pem) |
| 146 | + finally: |
| 147 | + cleanup() |
158 | 148 |
|
159 | 149 | return order |
160 | 150 |
|
|
0 commit comments