summaryrefslogtreecommitdiff
path: root/tools/comparecert.py
diff options
context:
space:
mode:
Diffstat (limited to 'tools/comparecert.py')
-rwxr-xr-xtools/comparecert.py35
1 files changed, 11 insertions, 24 deletions
diff --git a/tools/comparecert.py b/tools/comparecert.py
index 81893f7..e6864b6 100755
--- a/tools/comparecert.py
+++ b/tools/comparecert.py
@@ -20,31 +20,18 @@ import signal
import select
import zipfile
-def readfile(filename):
- contents = open(filename).read()
- certchain = get_certs_from_string(contents)
- precerts = get_precerts_from_string(contents)
- return (certchain, precerts)
+def readfile(filename, filetype):
+ if filetype == 'raw':
+ return open(filename, 'r').read()
+ else:
+ return get_pemlike(filename, filetype)
def testcerts(template, test):
- (certchain1, precerts1) = template
- (certchain2, precerts2) = test
+ blob1 = template
+ blob2 = test
- if precerts1 != precerts2:
- return (False, "precerts are different")
-
- if certchain1 == certchain2:
- return (True, "")
-
- if len(certchain2) == len(certchain1) + 1:
- if certchain2[:-1] != certchain1:
- return (False, "certchains are different")
- last_issuer = get_cert_info(certchain1[-1])["issuer"]
- root_subject = get_cert_info(certchain2[-1])["subject"]
- if last_issuer == root_subject:
- return (True, "fetched chain has an appended root cert")
- else:
- return (False, "fetched chain has an extra entry")
+ if blob1 == blob2:
+ return (True, "equal")
return (False, "certchains are different")
@@ -53,9 +40,9 @@ parser.add_argument('templates', help="Test templates, separated with colon")
parser.add_argument('test', help="Files to test, separated with colon")
args = parser.parse_args()
-templates = [readfile(filename) for filename in args.templates.split(":")]
+templates = [readfile(filename, 'raw') for filename in args.templates.split(":")]
-tests = [readfile(filename) for filename in args.test.split(":")]
+tests = [readfile(filename, 'BLOB')[0] for filename in args.test.split(":")]
for test in tests: