diff options
author | Linus Nordberg <linus@nordberg.se> | 2014-09-23 10:47:35 +0200 |
---|---|---|
committer | Linus Nordberg <linus@nordberg.se> | 2014-09-23 10:47:35 +0200 |
commit | 2284a317b5fe2f757dad20b67ff560dc7b91532f (patch) | |
tree | 0fe939a2ab5d35d0d59309598595c85b5397b476 /tools | |
parent | 560bcebb4cf64aea915331a55013b21696bfce5d (diff) |
Add whitespace in order to break long lines.certtools-whitespace
Also, use /usr/bin/env.
Diffstat (limited to 'tools')
-rw-r--r-- | tools/certtools.py | 22 | ||||
-rwxr-xr-x | tools/submitcert.py | 6 |
2 files changed, 17 insertions, 11 deletions
diff --git a/tools/certtools.py b/tools/certtools.py index 9d24c36..03ed1a4 100644 --- a/tools/certtools.py +++ b/tools/certtools.py @@ -6,8 +6,10 @@ import urllib2 import struct def get_cert_info(s): - p = subprocess.Popen(["openssl", "x509", "-noout", "-subject", "-issuer", "-inform", "der"], - stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + p = subprocess.Popen( + ["openssl", "x509", "-noout", "-subject", "-issuer", "-inform", "der"], + stdin=subprocess.PIPE, stdout=subprocess.PIPE, + stderr=subprocess.PIPE) parsed = p.communicate(s) if parsed[1]: print "error:", parsed[1] @@ -22,7 +24,7 @@ def get_certs_from_file(certfile): certs = [] cert = "" incert = False - + for line in open(certfile): line = line.strip() if line == "-----BEGIN CERTIFICATE-----": @@ -36,8 +38,9 @@ def get_certs_from_file(certfile): return certs def get_root_cert(issuer): - accepted_certs = json.loads(open("googlelog-accepted-certs.txt").read())["certificates"] - + accepted_certs = \ + json.loads(open("googlelog-accepted-certs.txt").read())["certificates"] + root_cert = None for accepted_cert in accepted_certs: @@ -54,9 +57,11 @@ def get_sth(baseurl): def get_proof_by_hash(baseurl, hash, tree_size): try: - params = urllib.urlencode({"hash":base64.b64encode(hash), "tree_size":tree_size}) + params = urllib.urlencode({"hash":base64.b64encode(hash), + "tree_size":tree_size}) print params - result = urllib2.urlopen(baseurl + "ct/v1/get-proof-by-hash?" + params).read() + result = \ + urllib2.urlopen(baseurl + "ct/v1/get-proof-by-hash?" + params).read() return result except urllib2.HTTPError, e: print e.read() @@ -68,7 +73,8 @@ def tls_array(data, length_len): def add_chain(baseurl, submission): try: - return json.loads(urllib2.urlopen(baseurl + "ct/v1/add-chain", json.dumps(submission)).read()) + return json.loads(urllib2.urlopen(baseurl + "ct/v1/add-chain", + json.dumps(submission)).read()) except urllib2.HTTPError, e: print e.read() sys.exit(1) diff --git a/tools/submitcert.py b/tools/submitcert.py index a4dd9a2..229d36c 100755 --- a/tools/submitcert.py +++ b/tools/submitcert.py @@ -1,5 +1,4 @@ -#!/usr/bin/python - +#!/usr/bin/env python import urllib2 import urllib import json @@ -31,7 +30,8 @@ if lookup_in_log: extensions = "" - timestamped_entry = struct.pack(">Q", result["timestamp"]) + entry_type + tls_array(base64.decodestring(certs[0]), 3) + tls_array(extensions, 2) + timestamped_entry = struct.pack(">Q", result["timestamp"]) + entry_type + \ + tls_array(base64.decodestring(certs[0]), 3) + tls_array(extensions, 2) version = struct.pack(">b", 0) leaf_type = struct.pack(">b", 0) merkle_tree_leaf = version + leaf_type + timestamped_entry |