summaryrefslogtreecommitdiff
path: root/tools/fetchacert.py
diff options
context:
space:
mode:
authorLinus Nordberg <linus@nordberg.se>2015-03-25 09:55:03 +0100
committerLinus Nordberg <linus@nordberg.se>2015-03-25 09:55:03 +0100
commit94282d502072f894f3168ef8c2c7527fe4a69e52 (patch)
tree0ae1b630221867acf3f56f08a042cbf94df3943a /tools/fetchacert.py
parent575d810afbcfcca99f701f3ea42de79bf6e283d1 (diff)
Add tools/fetchacert.py, fetching exactly one chain from a log.
Also move a piece of common code from fetchallcerts.py to certtools.py.
Diffstat (limited to 'tools/fetchacert.py')
-rwxr-xr-xtools/fetchacert.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/tools/fetchacert.py b/tools/fetchacert.py
new file mode 100755
index 0000000..82ea7c1
--- /dev/null
+++ b/tools/fetchacert.py
@@ -0,0 +1,22 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+import argparse
+import base64
+from certtools import *
+
+parser = argparse.ArgumentParser(description='')
+parser.add_argument('baseurl', help="Base URL for CT server")
+parser.add_argument('index', type=int, help="Index for entry to fetch")
+args = parser.parse_args()
+
+rawentries = get_entries(args.baseurl, args.index, args.index)["entries"]
+entry = extract_original_entry(rawentries[0])
+(chain, _timestamp, _issuer_key_hash) = entry
+s = ""
+for cert in chain:
+ s += "-----BEGIN CERTIFICATE-----\n"
+ s += base64.encodestring(cert).rstrip() + "\n"
+ s += "-----END CERTIFICATE-----\n"
+ s += "\n"
+print s