OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright (c) 2015 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2015 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Certificate chain with 2 intermediates. The first intermediate has a basic | 6 """Certificate chain where the intermediate sets pathlen=0, and is followed by |
7 constraints path length of 0. The second one is self-issued so does not count | 7 a self-issued intermediate.""" |
8 against the path length.""" | |
9 | 8 |
10 import sys | 9 import sys |
11 sys.path += ['..'] | 10 sys.path += ['..'] |
12 | 11 |
13 import common | 12 import common |
14 | 13 |
15 # Self-signed root certificate (used as trust anchor). | 14 # Self-signed root certificate. |
16 root = common.create_self_signed_root_certificate('Root') | 15 root = common.create_self_signed_root_certificate('Root') |
17 | 16 |
18 # Intermediate with pathlen 0 | 17 # Intermediate with pathlen 0 |
19 intermediate1 = common.create_intermediate_certificate('Intermediate', root) | 18 intermediate1 = common.create_intermediate_certificate('Intermediate', root) |
20 intermediate1.get_extensions().set_property('basicConstraints', | 19 intermediate1.get_extensions().set_property('basicConstraints', |
21 'critical,CA:true,pathlen:0') | 20 'critical,CA:true,pathlen:0') |
22 | 21 |
23 # Another intermediate (with the same pathlen restriction). | 22 # Another intermediate (with the same pathlen restriction). |
24 # Note that this is self-issued but NOT self-signed. | 23 # Note that this is self-issued but NOT self-signed. |
25 intermediate2 = common.create_intermediate_certificate('Intermediate', | 24 intermediate2 = common.create_intermediate_certificate('Intermediate', |
26 intermediate1) | 25 intermediate1) |
27 intermediate2.get_extensions().set_property('basicConstraints', | 26 intermediate2.get_extensions().set_property('basicConstraints', |
28 'critical,CA:true,pathlen:0') | 27 'critical,CA:true,pathlen:0') |
29 | 28 |
30 # Target certificate. | 29 # Target certificate. |
31 target = common.create_end_entity_certificate('Target', intermediate2) | 30 target = common.create_end_entity_certificate('Target', intermediate2) |
32 | 31 |
33 chain = [target, intermediate2, intermediate1, root] | 32 chain = [target, intermediate2, intermediate1, root] |
34 common.write_chain(__doc__, chain, 'chain.pem') | 33 common.write_chain(__doc__, chain, 'chain.pem') |
OLD | NEW |