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
|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2015, NORDUnet A/S.
# See LICENSE for licensing information.
import sys
import argparse
import yaml
from certtools import create_ssl_context, get_sth
def main():
parser = argparse.ArgumentParser(description='')
parser.add_argument('--raw', action='store_true',
help="Print all")
parser.add_argument('--timestamp', action='store_true',
help="Print timestamp")
parser.add_argument('--roothash', action='store_true',
help="Print root hash")
parser.add_argument('--treesize', action='store_true',
help="Print tree size")
parser.add_argument('--signature', action='store_true',
help="Print signature")
parser.add_argument('--config', help="System configuration")
parser.add_argument('--localconfig', help="Local configuration")
parser.add_argument('baseurl', help="Log base URL")
args = parser.parse_args()
paths = None
if (args.localconfig):
localconfig = yaml.load(open(args.localconfig))
paths = localconfig["paths"]
if ('https://' in args.baseurl):
if paths is None:
print >>stderr, "need --localconfig for CA cert"
return -1
create_ssl_context(cafile=paths["https_cacertfile"])
sth = get_sth(args.baseurl)
if args.raw:
print sth
if args.timestamp:
print sth['timestamp']
if args.roothash:
print sth['sha256_root_hash']
if args.treesize:
print sth['tree_size']
if args.signature:
print sth['tree_head_signature']
if __name__ == '__main__':
sys.exit(main())
|