summaryrefslogtreecommitdiff
path: root/tools/certtools.py
diff options
context:
space:
mode:
Diffstat (limited to 'tools/certtools.py')
-rw-r--r--tools/certtools.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/tools/certtools.py b/tools/certtools.py
index f6c1cd9..428d623 100644
--- a/tools/certtools.py
+++ b/tools/certtools.py
@@ -11,6 +11,7 @@ import sys
import hashlib
import ecdsa
import datetime
+import cStringIO
publickeys = {
"https://ct.googleapis.com/pilot/":
@@ -44,11 +45,14 @@ def get_cert_info(s):
def get_pemlike(filename, marker):
+ return get_pemlike_from_file(open(filename), marker)
+
+def get_pemlike_from_file(f, marker):
entries = []
entry = ""
inentry = False
- for line in open(filename):
+ for line in f:
line = line.strip()
if line == "-----BEGIN " + marker + "-----":
entry = ""
@@ -63,6 +67,10 @@ def get_pemlike(filename, marker):
def get_certs_from_file(certfile):
return get_pemlike(certfile, "CERTIFICATE")
+def get_certs_from_string(s):
+ f = cStringIO.StringIO(s)
+ return get_pemlike_from_file(f, "CERTIFICATE")
+
def get_eckey_from_file(keyfile):
keys = get_pemlike(keyfile, "EC PRIVATE KEY")
assert len(keys) == 1