Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
1 #!/usr/bin/python
2 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
3 # vim: set filetype=python:
4 #
5 # This Source Code Form is subject to the terms of the Mozilla Public
6 # License, v. 2.0. If a copy of the MPL was not distributed with this
7 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 import tempfile, os, sys
10 import random
11 import pexpect
12 import subprocess
13 import shutil
15 libpath = os.path.abspath('../psm_common_py')
17 sys.path.append(libpath)
19 import CertUtils
21 srcdir = os.getcwd()
22 db = tempfile.mkdtemp()
24 CA_basic_constraints = "basicConstraints = critical, CA:TRUE\n"
25 EE_basic_constraints = "basicConstraints = CA:FALSE\n"
27 CA_full_ku = ("keyUsage = digitalSignature, nonRepudiation, keyEncipherment, " +
28 "dataEncipherment, keyAgreement, keyCertSign, cRLSign\n")
30 CA_eku = ("extendedKeyUsage = critical, serverAuth, clientAuth, " +
31 "emailProtection, codeSigning\n")
33 authority_key_ident = "authorityKeyIdentifier = keyid, issuer\n"
34 subject_key_ident = "subjectKeyIdentifier = hash\n"
38 def generate_certs():
39 key_type = 'rsa'
40 ca_ext = CA_basic_constraints + CA_full_ku + subject_key_ident + CA_eku;
41 ee_ext_text = (EE_basic_constraints + authority_key_ident)
42 [ca_key, ca_cert] = CertUtils.generate_cert_generic(db,
43 srcdir,
44 1,
45 key_type,
46 'ca',
47 ca_ext)
49 [int_key, int_cert] = CertUtils.generate_cert_generic(db,
50 srcdir,
51 103,
52 key_type,
53 'int',
54 ca_ext,
55 ca_key,
56 ca_cert)
58 #now the ee
59 CertUtils.generate_cert_generic(db,
60 srcdir,
61 100,
62 key_type,
63 'ee',
64 ee_ext_text,
65 int_key,
66 int_cert)
72 generate_certs()