summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tools/certtools.py44
1 files changed, 26 insertions, 18 deletions
diff --git a/tools/certtools.py b/tools/certtools.py
index 84d0bd9..485a8ac 100644
--- a/tools/certtools.py
+++ b/tools/certtools.py
@@ -180,14 +180,18 @@ def unpack_tls_array(packed_data, length_len):
def add_chain(baseurl, submission, session=None):
try:
- result = urlpost(baseurl + "ct/v1/add-chain", json.dumps(submission), session=session)
- if result.status_code == requests.codes.ok:
- return result.json()
- else:
- print "ERROR:", result.status_code, result.text
- if result.status_code == 400:
- return None
- sys.exit(1)
+ while True:
+ result = urlpost(baseurl + "ct/v1/add-chain", json.dumps(submission), session=session)
+ if result.status_code == requests.codes.ok:
+ return result.json()
+ else:
+ print "ERROR:", result.status_code, result.text
+ if result.status_code == 400:
+ return None
+ if result.status_code == 429:
+ sleep(1)
+ continue
+ sys.exit(1)
except ValueError, e:
print "==== FAILED REQUEST ===="
print submission
@@ -198,16 +202,20 @@ def add_chain(baseurl, submission, session=None):
def add_prechain(baseurl, submission, session=None):
try:
- result = urlpost(baseurl + "ct/v1/add-pre-chain",
- json.dumps(submission), session=session)
-
- if result.status_code == requests.codes.ok:
- return result.json()
- else:
- print "ERROR:", result.status_code, result.text
- if result.status_code == 400:
- return None
- sys.exit(1)
+ while True:
+ result = urlpost(baseurl + "ct/v1/add-pre-chain",
+ json.dumps(submission), session=session)
+
+ if result.status_code == requests.codes.ok:
+ return result.json()
+ else:
+ print "ERROR:", result.status_code, result.text
+ if result.status_code == 400:
+ return None
+ if result.status_code == 429:
+ sleep(1)
+ continue
+ sys.exit(1)
except ValueError, e:
print "==== FAILED REQUEST ===="
print submission