summaryrefslogtreecommitdiff
path: root/tools/certtools.py
diff options
context:
space:
mode:
Diffstat (limited to 'tools/certtools.py')
-rw-r--r--tools/certtools.py22
1 files changed, 14 insertions, 8 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)