OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright (c) 2016 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2016 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 and one end entity certificate. The | 6 """Certificate chain with 2 intermediates and one end entity certificate. The |
7 root certificate has a pathlen:1 restriction, and constraints are enforced | 7 root certificate has a pathlen:1 restriction, and constraints are enforced |
8 on this trust anchor making it an invalid chain.""" | 8 on this trust anchor making it an invalid chain.""" |
9 | 9 |
| 10 import sys |
| 11 sys.path += ['..'] |
| 12 |
10 import common | 13 import common |
11 | 14 |
12 # Self-signed root certificate (used as trust anchor). | 15 # Self-signed root certificate (used as trust anchor). |
13 root = common.create_self_signed_root_certificate('Root') | 16 root = common.create_self_signed_root_certificate('Root') |
14 root.get_extensions().set_property('basicConstraints', | 17 root.get_extensions().set_property('basicConstraints', |
15 'critical,CA:true,pathlen:1') | 18 'critical,CA:true,pathlen:1') |
16 | 19 |
17 # Intermediate 1 (no pathlen restriction). | 20 # Intermediate 1 (no pathlen restriction). |
18 intermediate1 = common.create_intermediate_certificate('Intermediate1', root) | 21 intermediate1 = common.create_intermediate_certificate('Intermediate1', root) |
19 | 22 |
20 # Intermediate 2 (no pathlen restriction). | 23 # Intermediate 2 (no pathlen restriction). |
21 intermediate2 = common.create_intermediate_certificate('Intermediate2', | 24 intermediate2 = common.create_intermediate_certificate('Intermediate2', |
22 intermediate1) | 25 intermediate1) |
23 | 26 |
24 # Target certificate. | 27 # Target certificate. |
25 target = common.create_end_entity_certificate('Target', intermediate2) | 28 target = common.create_end_entity_certificate('Target', intermediate2) |
26 | 29 |
27 chain = [target, intermediate2, intermediate1] | 30 chain = [target, intermediate2, intermediate1, root] |
28 trusted = common.TrustAnchor(root, constrained=True) | 31 common.write_chain(__doc__, chain, 'chain.pem') |
29 time = common.DEFAULT_TIME | |
30 key_purpose = common.DEFAULT_KEY_PURPOSE | |
31 verify_result = False | |
32 errors = """----- Certificate i=1 (CN=Intermediate2) ----- | |
33 ERROR: max_path_length reached | |
34 | |
35 """ | |
36 | |
37 common.write_test_file(__doc__, chain, trusted, time, key_purpose, | |
38 verify_result, errors) | |
OLD | NEW |