OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2016 The Chromium Authors. All rights reserved. | 2 # Copyright 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 import os | 6 import os |
7 import sys | 7 import sys |
8 sys.path += [os.path.join('..', 'verify_certificate_chain_unittest')] | 8 sys.path += [os.path.join('..', 'verify_certificate_chain_unittest')] |
9 | 9 |
10 import common | 10 import common |
11 | 11 |
12 | 12 |
13 # Self-signed root certificate. Not saved to a .pem since the test doesn't need | 13 # Self-signed root certificate. Not saved to a .pem since the test doesn't need |
14 # it. | 14 # it. |
15 root = common.create_self_signed_root_certificate('Root') | 15 root = common.create_self_signed_root_certificate('Root') |
16 | 16 |
17 | 17 |
18 # Intermediary certificates. All have the same subject and key. | 18 # Intermediate certificates. All have the same subject and key. |
19 i_base = common.create_intermediary_certificate('I', root) | 19 i_base = common.create_intermediate_certificate('I', root) |
20 common.write_string_to_file(i_base.get_cert_pem(), 'i.pem') | 20 common.write_string_to_file(i_base.get_cert_pem(), 'i.pem') |
21 | 21 |
22 i2 = common.create_intermediary_certificate('I', root) | 22 i2 = common.create_intermediate_certificate('I', root) |
23 i2.set_key_path(i_base.get_key_path()) | 23 i2.set_key_path(i_base.get_key_path()) |
24 common.write_string_to_file(i2.get_cert_pem(), 'i2.pem') | 24 common.write_string_to_file(i2.get_cert_pem(), 'i2.pem') |
25 | 25 |
26 i3 = common.create_intermediary_certificate('I', root) | 26 i3 = common.create_intermediate_certificate('I', root) |
27 i3.set_key_path(i_base.get_key_path()) | 27 i3.set_key_path(i_base.get_key_path()) |
28 common.write_string_to_file(i3.get_cert_pem(), 'i3.pem') | 28 common.write_string_to_file(i3.get_cert_pem(), 'i3.pem') |
29 | 29 |
30 | 30 |
31 # More Intermediary certificates, which are just to generate the proper config | 31 # More Intermediate certificates, which are just to generate the proper config |
32 # files so the target certs will have the desired Authority Information Access | 32 # files so the target certs will have the desired Authority Information Access |
33 # values. These ones aren't saved to files. | 33 # values. These ones aren't saved to files. |
34 i_no_aia = common.create_intermediary_certificate('I', root) | 34 i_no_aia = common.create_intermediate_certificate('I', root) |
35 i_no_aia.set_key_path(i_base.get_key_path()) | 35 i_no_aia.set_key_path(i_base.get_key_path()) |
36 section = i_no_aia.config.get_section('signing_ca_ext') | 36 section = i_no_aia.config.get_section('signing_ca_ext') |
37 section.set_property('authorityInfoAccess', None) | 37 section.set_property('authorityInfoAccess', None) |
38 | 38 |
39 i_two_aia = common.create_intermediary_certificate('I', root) | 39 i_two_aia = common.create_intermediate_certificate('I', root) |
40 i_two_aia.set_key_path(i_base.get_key_path()) | 40 i_two_aia.set_key_path(i_base.get_key_path()) |
41 section = i_two_aia.config.get_section('issuer_info') | 41 section = i_two_aia.config.get_section('issuer_info') |
42 section.set_property('caIssuers;URI.1', 'http://url-for-aia2/I2.foo') | 42 section.set_property('caIssuers;URI.1', 'http://url-for-aia2/I2.foo') |
43 | 43 |
44 i_three_aia = common.create_intermediary_certificate('I', root) | 44 i_three_aia = common.create_intermediate_certificate('I', root) |
45 i_three_aia.set_key_path(i_base.get_key_path()) | 45 i_three_aia.set_key_path(i_base.get_key_path()) |
46 section = i_three_aia.config.get_section('issuer_info') | 46 section = i_three_aia.config.get_section('issuer_info') |
47 section.set_property('caIssuers;URI.1', 'http://url-for-aia2/I2.foo') | 47 section.set_property('caIssuers;URI.1', 'http://url-for-aia2/I2.foo') |
48 section.set_property('caIssuers;URI.2', 'http://url-for-aia3/I3.foo') | 48 section.set_property('caIssuers;URI.2', 'http://url-for-aia3/I3.foo') |
49 | 49 |
50 i_six_aia = common.create_intermediary_certificate('I', root) | 50 i_six_aia = common.create_intermediate_certificate('I', root) |
51 i_six_aia.set_key_path(i_base.get_key_path()) | 51 i_six_aia.set_key_path(i_base.get_key_path()) |
52 section = i_six_aia.config.get_section('issuer_info') | 52 section = i_six_aia.config.get_section('issuer_info') |
53 section.set_property('caIssuers;URI.1', 'http://url-for-aia2/I2.foo') | 53 section.set_property('caIssuers;URI.1', 'http://url-for-aia2/I2.foo') |
54 section.set_property('caIssuers;URI.2', 'http://url-for-aia3/I3.foo') | 54 section.set_property('caIssuers;URI.2', 'http://url-for-aia3/I3.foo') |
55 section.set_property('caIssuers;URI.3', 'http://url-for-aia4/I4.foo') | 55 section.set_property('caIssuers;URI.3', 'http://url-for-aia4/I4.foo') |
56 section.set_property('caIssuers;URI.4', 'http://url-for-aia5/I5.foo') | 56 section.set_property('caIssuers;URI.4', 'http://url-for-aia5/I5.foo') |
57 section.set_property('caIssuers;URI.5', 'http://url-for-aia6/I6.foo') | 57 section.set_property('caIssuers;URI.5', 'http://url-for-aia6/I6.foo') |
58 | 58 |
59 i_file_aia = common.create_intermediary_certificate('I', root) | 59 i_file_aia = common.create_intermediate_certificate('I', root) |
60 i_file_aia.set_key_path(i_base.get_key_path()) | 60 i_file_aia.set_key_path(i_base.get_key_path()) |
61 section = i_file_aia.config.get_section('issuer_info') | 61 section = i_file_aia.config.get_section('issuer_info') |
62 section.set_property('caIssuers;URI.0', 'file:///dev/null') | 62 section.set_property('caIssuers;URI.0', 'file:///dev/null') |
63 | 63 |
64 i_invalid_url_aia = common.create_intermediary_certificate('I', root) | 64 i_invalid_url_aia = common.create_intermediate_certificate('I', root) |
65 i_invalid_url_aia.set_key_path(i_base.get_key_path()) | 65 i_invalid_url_aia.set_key_path(i_base.get_key_path()) |
66 section = i_invalid_url_aia.config.get_section('issuer_info') | 66 section = i_invalid_url_aia.config.get_section('issuer_info') |
67 section.set_property('caIssuers;URI.0', 'foobar') | 67 section.set_property('caIssuers;URI.0', 'foobar') |
68 | 68 |
69 i_file_and_http_aia = common.create_intermediary_certificate('I', root) | 69 i_file_and_http_aia = common.create_intermediate_certificate('I', root) |
70 i_file_and_http_aia.set_key_path(i_base.get_key_path()) | 70 i_file_and_http_aia.set_key_path(i_base.get_key_path()) |
71 section = i_file_and_http_aia.config.get_section('issuer_info') | 71 section = i_file_and_http_aia.config.get_section('issuer_info') |
72 section.set_property('caIssuers;URI.0', 'file:///dev/null') | 72 section.set_property('caIssuers;URI.0', 'file:///dev/null') |
73 section.set_property('caIssuers;URI.1', 'http://url-for-aia2/I2.foo') | 73 section.set_property('caIssuers;URI.1', 'http://url-for-aia2/I2.foo') |
74 | 74 |
75 i_invalid_and_http_aia = common.create_intermediary_certificate('I', root) | 75 i_invalid_and_http_aia = common.create_intermediate_certificate('I', root) |
76 i_invalid_and_http_aia.set_key_path(i_base.get_key_path()) | 76 i_invalid_and_http_aia.set_key_path(i_base.get_key_path()) |
77 section = i_invalid_and_http_aia.config.get_section('issuer_info') | 77 section = i_invalid_and_http_aia.config.get_section('issuer_info') |
78 section.set_property('caIssuers;URI.0', 'foobar') | 78 section.set_property('caIssuers;URI.0', 'foobar') |
79 section.set_property('caIssuers;URI.1', 'http://url-for-aia2/I2.foo') | 79 section.set_property('caIssuers;URI.1', 'http://url-for-aia2/I2.foo') |
80 | 80 |
81 | 81 |
82 # target certs | 82 # target certs |
83 | 83 |
84 target = common.create_end_entity_certificate('target', i_base) | 84 target = common.create_end_entity_certificate('target', i_base) |
85 common.write_string_to_file(target.get_cert_pem(), 'target_one_aia.pem') | 85 common.write_string_to_file(target.get_cert_pem(), 'target_one_aia.pem') |
(...skipping 17 matching lines...) Expand all Loading... |
103 common.write_string_to_file(target.get_cert_pem(), 'target_invalid_url_aia.pem') | 103 common.write_string_to_file(target.get_cert_pem(), 'target_invalid_url_aia.pem') |
104 | 104 |
105 target = common.create_end_entity_certificate('target', i_file_and_http_aia) | 105 target = common.create_end_entity_certificate('target', i_file_and_http_aia) |
106 common.write_string_to_file(target.get_cert_pem(), | 106 common.write_string_to_file(target.get_cert_pem(), |
107 'target_file_and_http_aia.pem') | 107 'target_file_and_http_aia.pem') |
108 | 108 |
109 target = common.create_end_entity_certificate('target', i_invalid_and_http_aia) | 109 target = common.create_end_entity_certificate('target', i_invalid_and_http_aia) |
110 common.write_string_to_file(target.get_cert_pem(), | 110 common.write_string_to_file(target.get_cert_pem(), |
111 'target_invalid_and_http_aia.pem') | 111 'target_invalid_and_http_aia.pem') |
112 | 112 |
OLD | NEW |