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
michael@0 | 1 | #!/usr/bin/python |
michael@0 | 2 | # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*- |
michael@0 | 3 | # vim: set filetype=python |
michael@0 | 4 | |
michael@0 | 5 | # This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 6 | # License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 7 | # file, You can obtain one at http://mozilla.org/MPL/2.0/. |
michael@0 | 8 | |
michael@0 | 9 | import tempfile, os, sys |
michael@0 | 10 | |
michael@0 | 11 | libpath = os.path.abspath('../psm_common_py') |
michael@0 | 12 | sys.path.append(libpath) |
michael@0 | 13 | import CertUtils |
michael@0 | 14 | |
michael@0 | 15 | srcdir = os.getcwd() |
michael@0 | 16 | db = tempfile.mkdtemp() |
michael@0 | 17 | |
michael@0 | 18 | def generate_child_cert(db_dir, dest_dir, noise_file, name, ca_nick, |
michael@0 | 19 | cert_version, do_bc, is_ee): |
michael@0 | 20 | return CertUtils.generate_child_cert(db_dir, dest_dir, noise_file, name, |
michael@0 | 21 | ca_nick, cert_version, do_bc, is_ee, '') |
michael@0 | 22 | |
michael@0 | 23 | def generate_ee_family(db_dir, dest_dir, noise_file, ca_name): |
michael@0 | 24 | name = "v1_ee-"+ ca_name; |
michael@0 | 25 | generate_child_cert(db_dir, dest_dir, noise_file, name, ca_name, 1, False, True) |
michael@0 | 26 | name = "v1_bc_ee-"+ ca_name; |
michael@0 | 27 | generate_child_cert(db_dir, dest_dir, noise_file, name, ca_name, 1, True, True) |
michael@0 | 28 | |
michael@0 | 29 | name = "v2_ee-"+ ca_name; |
michael@0 | 30 | generate_child_cert(db_dir, dest_dir, noise_file, name, ca_name, 2, False, True) |
michael@0 | 31 | name = "v2_bc_ee-"+ ca_name; |
michael@0 | 32 | generate_child_cert(db_dir, dest_dir, noise_file, name, ca_name, 2, True, True) |
michael@0 | 33 | |
michael@0 | 34 | name = "v3_missing_bc_ee-"+ ca_name; |
michael@0 | 35 | generate_child_cert(db_dir, dest_dir, noise_file, name, ca_name, 3, False, True) |
michael@0 | 36 | name = "v3_bc_ee-"+ ca_name; |
michael@0 | 37 | generate_child_cert(db_dir, dest_dir, noise_file, name, ca_name, 3, True, True) |
michael@0 | 38 | |
michael@0 | 39 | name = "v4_bc_ee-"+ ca_name; |
michael@0 | 40 | generate_child_cert(db_dir, dest_dir, noise_file, name, ca_name, 4, True, True) |
michael@0 | 41 | |
michael@0 | 42 | def generate_intermediates_and_ee_set(db_dir, dest_dir, noise_file, ca_name): |
michael@0 | 43 | name = "v1_int-" + ca_name; |
michael@0 | 44 | generate_child_cert(db, srcdir, noise_file, name, ca_name, 1, False, False) |
michael@0 | 45 | generate_ee_family(db, srcdir, noise_file, name) |
michael@0 | 46 | name = "v1_int_bc-" + ca_name; |
michael@0 | 47 | generate_child_cert(db, srcdir, noise_file, name, ca_name, 1, True, False) |
michael@0 | 48 | generate_ee_family(db, srcdir, noise_file, name) |
michael@0 | 49 | |
michael@0 | 50 | name = "v2_int-" + ca_name; |
michael@0 | 51 | generate_child_cert(db, srcdir, noise_file, name, ca_name, 2, False, False) |
michael@0 | 52 | generate_ee_family(db, srcdir, noise_file, name) |
michael@0 | 53 | name = "v2_int_bc-" + ca_name; |
michael@0 | 54 | generate_child_cert(db, srcdir, noise_file, name, ca_name, 2, True, False) |
michael@0 | 55 | generate_ee_family(db, srcdir, noise_file, name) |
michael@0 | 56 | |
michael@0 | 57 | name = "v3_int_missing_bc-" + ca_name; |
michael@0 | 58 | generate_child_cert(db, srcdir, noise_file, name, ca_name, 3, False, False) |
michael@0 | 59 | generate_ee_family(db, srcdir, noise_file, name) |
michael@0 | 60 | name = "v3_int-" + ca_name; |
michael@0 | 61 | generate_child_cert(db, srcdir, noise_file, name, ca_name, 3, True, False) |
michael@0 | 62 | generate_ee_family(db, srcdir, noise_file, name) |
michael@0 | 63 | |
michael@0 | 64 | def generate_ca(db_dir, dest_dir, noise_file, name, version, do_bc): |
michael@0 | 65 | CertUtils.generate_ca_cert(db_dir, dest_dir, noise_file, name, version, do_bc) |
michael@0 | 66 | generate_intermediates_and_ee_set(db_dir, dest_dir, noise_file, name) |
michael@0 | 67 | |
michael@0 | 68 | def generate_certs(): |
michael@0 | 69 | [noise_file, pwd_file] = CertUtils.init_nss_db(db) |
michael@0 | 70 | generate_ca(db, srcdir, noise_file, "v1_ca", 1, False ) |
michael@0 | 71 | generate_ca(db, srcdir, noise_file, "v1_ca_bc", 1, True) |
michael@0 | 72 | generate_ca(db, srcdir, noise_file, "v2_ca", 2, False ) |
michael@0 | 73 | generate_ca(db, srcdir, noise_file, "v2_ca_bc", 2, True) |
michael@0 | 74 | generate_ca(db, srcdir, noise_file, "v3_ca", 3, True ) |
michael@0 | 75 | generate_ca(db, srcdir, noise_file, "v3_ca_missing_bc", 3, False) |
michael@0 | 76 | |
michael@0 | 77 | generate_certs(); |