aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xsigsum-witness.py15
1 files changed, 12 insertions, 3 deletions
diff --git a/sigsum-witness.py b/sigsum-witness.py
index ef63c4c..5cd9f7a 100755
--- a/sigsum-witness.py
+++ b/sigsum-witness.py
@@ -279,7 +279,10 @@ def store_tree_head(tree_head):
f.write(tree_head.text())
def fetch_tree_head_and_verify(log_verification_key):
- req = requests.get(g_args.base_url + 'sigsum/v0/get-tree-head-to-cosign')
+ try:
+ req = requests.get(g_args.base_url + 'sigsum/v0/get-tree-head-to-cosign')
+ except requests.ConnectionError as err:
+ return None, (ERR_TREEHEAD_FETCH, f"ERROR: unable to fetch new tree head: {err}")
if req.status_code != 200:
return None, (ERR_TREEHEAD_FETCH,
"ERROR: unable to fetch new tree head: {}".format(req.status_code))
@@ -293,7 +296,10 @@ def fetch_tree_head_and_verify(log_verification_key):
def fetch_consistency_proof(first, second):
url = g_args.base_url + 'sigsum/v0/get-consistency-proof/{}/{}'.format(first, second)
- req = requests.get(url)
+ try:
+ req = requests.get(url)
+ except requests.ConnectionError as err:
+ return None, (ERR_TREEHEAD_FETCH, f"ERROR: unable to fetch consistency proof: {err}")
if req.status_code != 200:
return None, (ERR_CONSISTENCYPROOF_FETCH,
"ERROR: unable to fetch consistency proof: {}".format(req.status_code))
@@ -354,7 +360,10 @@ def sign_send_store_tree_head(signing_key, log_key, tree_head):
post_data = 'cosignature={}\n'.format(hexlify(signature).decode('ascii'))
post_data += 'key_hash={}\n'.format(hash.hexdigest())
- req = requests.post(g_args.base_url + 'sigsum/v0/add-cosignature', post_data)
+ try:
+ req = requests.post(g_args.base_url + 'sigsum/v0/add-cosignature', post_data)
+ except requests.ConnectionError as err:
+ return (ERR_COSIG_POST, f"ERROR: Unable to post signature to log: {err}")
if req.status_code != 200:
return (ERR_COSIG_POST,
"ERROR: Unable to post signature to log: {} => {}: {}". format(req.url,