blob: 6d2bbf2df681d7446546ad6e9e9bb3ca7ab8a915 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
#!/usr/bin/env python
# Copyright (c) 2014, NORDUnet A/S.
# See LICENSE for licensing information.
import argparse
import urllib2
import urllib
import json
import base64
import sys
import struct
import hashlib
import itertools
from certtools import *
from certtools import *
from precerttools import *
import os
import signal
import select
import zipfile
parser = argparse.ArgumentParser(description='')
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()
file1contents = open(args.templates).read()
certchain1 = get_certs_from_string(file1contents)
precerts1 = get_precerts_from_string(file1contents)
file2contents = open(args.test).read()
certchain2 = get_certs_from_string(file2contents)
precerts2 = get_precerts_from_string(file2contents)
if precerts1 != precerts2:
print "precerts are different"
sys.exit(1)
if certchain1 == certchain2:
sys.exit(0)
if len(certchain2) == len(certchain1) + 1:
if certchain2[:-1] != certchain1:
print "certchains are different"
sys.exit(1)
last_issuer = get_cert_info(certchain1[-1])["issuer"]
root_subject = get_cert_info(certchain2[-1])["subject"]
if last_issuer == root_subject:
print "fetched chain has an appended root cert"
sys.exit(0)
else:
print "fetched chain has an extra entry"
sys.exit(1)
print "certchains are different"
sys.exit(1)
|