| 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, however |
| 7 constraints path length of 0, so it is a violation for it to have a subordinate | 7 violates this by issuing another (non-self-issued) intermediate.""" |
| 8 intermediate.""" | |
| 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('Intermediate1', root) | 18 intermediate1 = common.create_intermediate_certificate('Intermediate1', 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 intermediate2 = common.create_intermediate_certificate('Intermediate2', | 23 intermediate2 = common.create_intermediate_certificate('Intermediate2', |
| 25 intermediate1) | 24 intermediate1) |
| 26 intermediate2.get_extensions().set_property('basicConstraints', | 25 intermediate2.get_extensions().set_property('basicConstraints', |
| 27 'critical,CA:true,pathlen:0') | 26 'critical,CA:true,pathlen:0') |
| 28 | 27 |
| 29 # Target certificate. | 28 # Target certificate. |
| 30 target = common.create_end_entity_certificate('Target', intermediate2) | 29 target = common.create_end_entity_certificate('Target', intermediate2) |
| 31 | 30 |
| 32 chain = [target, intermediate2, intermediate1, root] | 31 chain = [target, intermediate2, intermediate1, root] |
| 33 common.write_chain(__doc__, chain, 'chain.pem') | 32 common.write_chain(__doc__, chain, 'chain.pem') |
| OLD | NEW |