summaryrefslogtreecommitdiff
path: root/monitor/josef_monitor.py
diff options
context:
space:
mode:
Diffstat (limited to 'monitor/josef_monitor.py')
-rwxr-xr-xmonitor/josef_monitor.py39
1 files changed, 9 insertions, 30 deletions
diff --git a/monitor/josef_monitor.py b/monitor/josef_monitor.py
index d23f292..05fae79 100755
--- a/monitor/josef_monitor.py
+++ b/monitor/josef_monitor.py
@@ -3,7 +3,7 @@
# Selected dependencies
# python-dev (apt)
-# pycrypto (pip)
+# python-crypto (apt)
# leveldb (pip)
import time
@@ -29,8 +29,10 @@ args = parser.parse_args()
if os.path.isfile(args.config):
modules = map(__import__, [args.config[:-2]])
CONFIG = modules[0]
+ ERROR_STR = CONFIG.ERROR_STR
else:
print "Config file not found!"
+ ERROR_STR = "ERROR: "
sys.exit()
@@ -151,9 +153,14 @@ class ctlog:
self.log("STH updated. Size: " + str(new_sth["tree_size"]) + ", Time: " + sth_time)
self.sth = new_sth
+ def get_all_roots(self):
+ result = urlopen(self.url + "ct/v1/get-roots").read()
+ certs = json.loads(result)["certificates"]
+ return certs
+
def update_roots(self):
try:
- roots = get_all_roots(self.url)
+ roots = self.get_all_roots()
except Exception, e:
self.log(ERROR_STR + "Failed to fetch roots. " + str(e))
return
@@ -176,7 +183,6 @@ class ctlog:
added, removed = compare_lists(hash_list, loaded_list)
if len(added) != 0:
- # self.log(str(len(added)) + " new roots added")
for item in added:
root_cert = base64.decodestring(roots[hash_list.index(item)])
subject = get_cert_info(root_cert)["subject"]
@@ -194,7 +200,6 @@ class ctlog:
if len(removed) != 0:
- # self.log(str(len(removed)) + " roots removed")
for item in removed:
data = open(cert_dir + "/" + item).read()
root_cert = base64.decodestring(data)
@@ -227,11 +232,9 @@ class ctlog:
elif age > 12 * 3600:
s = "WARNING: STH is older than 12h: %s UTC" % (sth_time)
self.log(s)
- # print s
elif age > 6 * 3600:
s = "WARNING: STH is older than 6h: %s UTC" % (sth_time)
self.log(s)
- # print s
except Exception, e:
self.log(ERROR_STR + "Failed to verify progress! Old:" + str(old) + " New:" + str(new) + " Exception: " + str(e))
print "Failed to verify progress in " + self.name
@@ -286,27 +289,7 @@ class ctlog:
# print time.strftime('%H:%M:%S') + " ERROR: Failed to prove inclusion of all new entries in " + url
# errors.append(time.strftime('%H:%M:%S') + " ERROR: Failed to prove inclusion of all new entries in " + url)
-def check_domain(raw_entry, log=None):
- orig_entry = extract_original_entry(raw_entry)
- try:
- cert_info = my_get_cert_info(orig_entry[0][0])
- if log:
- cert_info["log"] = log[8:-1] # strip generic URL stuff
- return cert_info
- except IndexError:
- return None
-
-def verify_subtree(sth, subtree, base_url):
- try:
- tmp = deepcopy(subtree)
- root = base64.b64encode(reduce_subtree_to_root(tmp)[0])
- if root == sth["sha256_root_hash"]:
- return True
- else:
- return False
- except:
- return False
# def verify_inclusion_by_hash(base_url, leaf_hash):
# try:
@@ -359,10 +342,6 @@ def verify_subtree(sth, subtree, base_url):
# print "ERROR:", e.read()
# sys.exit(0)
-def get_all_roots(base_url):
- result = urlopen(base_url + "ct/v1/get-roots").read()
- certs = json.loads(result)["certificates"]
- return certs
def setup_domain_monitoring():
monitored_domains = []