Chromium Code Reviews| Index: net/data/cert_issuer_source_static_unittest/generate-certs.py |
| diff --git a/net/data/cert_issuer_source_static_unittest/generate-certs.py b/net/data/cert_issuer_source_static_unittest/generate-certs.py |
| new file mode 100755 |
| index 0000000000000000000000000000000000000000..c67cc81ebe4129e5ede3e224eec1d2b6155dd2bd |
| --- /dev/null |
| +++ b/net/data/cert_issuer_source_static_unittest/generate-certs.py |
| @@ -0,0 +1,74 @@ |
| +#!/usr/bin/env python |
| +# Copyright 2016 The Chromium Authors. All rights reserved. |
| +# Use of this source code is governed by a BSD-style license that can be |
| +# found in the LICENSE file. |
| + |
| +"""Certificates for testing issuer lookup. |
| + |
| + Root |
| + /| | |
| + / | | |
| + / | | |
| + / | | |
| + / | | |
| + v v v |
| + I1_1 i1_2 I2 |
| + | | | |
| + | | | |
| + | | | |
| + | | | |
| + v v v |
| + C1 C2 D |
| + |
| +I1 (i1_1.pem) and i1 (i1_2.pem) have subjects that are equal after |
|
eroman
2016/06/01 23:30:23
are these names updated? (I don't see i1 in the di
mattm
2016/06/01 23:48:33
That's i1_2 in the diagram. I can't have the diagr
|
| +normalization. |
| + |
| +C1 and C2 should (attempt to) chain up through both I1 and i1, since I1 and i1 |
| +have the same the name (after normalization). |
| +""" |
| + |
| +import os |
| +import sys |
| +sys.path += [os.path.join('..', 'verify_certificate_chain_unittest')] |
| + |
| +import common |
| + |
| + |
| +def write_cert_to_file(cert, filename): |
| + common.write_string_to_file( |
| + "Generated by %s.\n" |
| + "Refer to generator script docstring for details.\n%s" % ( |
| + sys.argv[0], cert.get_cert_pem()), |
| + filename) |
| + |
| + |
| +# Self-signed root certificate |
| +root = common.create_self_signed_root_certificate('Root') |
| +write_cert_to_file(root, 'root.pem') |
| + |
| + |
| +# Intermediary certificates |
| +i1_1 = common.create_intermediary_certificate('I1', root) |
| +write_cert_to_file(i1_1, 'i1_1.pem') |
| + |
| +# same name (after normalization), different key |
| +i1_2 = common.create_intermediary_certificate('i1', root) |
| +write_cert_to_file(i1_2, 'i1_2.pem') |
| + |
| +# different name |
| +i2 = common.create_intermediary_certificate('I2', root) |
| +write_cert_to_file(i2, 'i2.pem') |
| + |
| + |
| +# target certs |
| + |
| +c1 = common.create_end_entity_certificate('C1', i1_1) |
| +write_cert_to_file(c1, 'c1.pem') |
| + |
| +c2 = common.create_end_entity_certificate('C2', i1_2) |
| +write_cert_to_file(c2, 'c2.pem') |
| + |
| +d = common.create_end_entity_certificate('D', i2) |
| +write_cert_to_file(d, 'd.pem') |
| + |
| + |