aboutsummaryrefslogtreecommitdiff
path: root/scripts/manifests.py
blob: 4991ffa28e8bb3f652f5ac0b6d1fe8795711a4f1 (plain) (blame)
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
# $Id$

import rpki.x509, rpki.manifest, time, POW, POW.pkix, glob, os

def one_cert(filename):
  c = rpki.x509.X509(Auto_file = filename)
  d = POW.Digest(POW.SHA256_DIGEST)
  d.update(c.get_DER())
  return filename.rpartition("/")[2], d.digest()

now = time.time()

certs = glob.glob("resource-cert-samples/*.cer")

mani = rpki.manifest.Manifest()
mani.set((0,                                   # version
          17,                                  # manifestNumber
          POW.pkix.time2gen(now),              # thisUpdate
          POW.pkix.time2gen(now + 24*60*60),   # nextUpdate
          (2, 16, 840, 1, 101, 3, 4, 2, 1),    # id-sha256
          [one_cert(i) for i in certs]))

f = os.popen("dumpasn1 -a - 2>/dev/null", "w")
f.write(mani.toString())
f.close()