OLD | NEW |
1 #!/bin/sh | 1 #!/bin/sh |
2 | 2 |
3 # Copyright 2013 The Chromium Authors. All rights reserved. | 3 # Copyright 2013 The Chromium Authors. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 # This script generates a set of test (end-entity, intermediate, root) | 7 # This script generates a set of test (end-entity, intermediate, root) |
8 # certificates that can be used to test fetching of an intermediate via AIA. | 8 # certificates that can be used to test fetching of an intermediate via AIA. |
9 | 9 |
10 try() { | 10 try() { |
11 "$@" || (e=$?; echo "$@" > /dev/stderr; exit $e) | 11 echo "$@" |
| 12 "$@" || exit 1 |
12 } | 13 } |
13 | 14 |
14 try rm -rf out | 15 try rm -rf out |
15 try mkdir out | 16 try mkdir out |
16 | 17 |
17 try /bin/sh -c "echo 01 > out/2048-sha256-root-serial" | 18 try /bin/sh -c "echo 01 > out/2048-sha256-root-serial" |
18 touch out/2048-sha256-root-index.txt | 19 touch out/2048-sha256-root-index.txt |
19 | 20 |
20 # Generate the key | 21 # Generate the key |
21 try openssl genrsa -out out/2048-sha256-root.key 2048 | 22 try openssl genrsa -out out/2048-sha256-root.key 2048 |
22 | 23 |
23 # Generate the root certificate | 24 # Generate the root certificate |
24 CA_COMMON_NAME="Test Root CA" \ | 25 CA_COMMON_NAME="Test Root CA" \ |
25 try openssl req \ | 26 try openssl req \ |
26 -new \ | 27 -new \ |
27 -key out/2048-sha256-root.key \ | 28 -key out/2048-sha256-root.key \ |
28 -out out/2048-sha256-root.req \ | 29 -out out/2048-sha256-root.req \ |
29 -config ca.cnf | 30 -config ca.cnf |
30 | 31 |
31 CA_COMMON_NAME="Test Root CA" \ | 32 CA_COMMON_NAME="Test Root CA" \ |
32 try openssl x509 \ | 33 try openssl x509 \ |
33 -req -days 3650 \ | 34 -req -days 3650 \ |
34 -in out/2048-sha256-root.req \ | 35 -in out/2048-sha256-root.req \ |
| 36 -out out/2048-sha256-root.pem \ |
35 -signkey out/2048-sha256-root.key \ | 37 -signkey out/2048-sha256-root.key \ |
36 -extfile ca.cnf \ | 38 -extfile ca.cnf \ |
37 -extensions ca_cert \ | 39 -extensions ca_cert \ |
38 -text > out/2048-sha256-root.pem | 40 -text |
39 | 41 |
40 # Generate the leaf certificate requests | 42 # Generate the leaf certificate requests |
41 try openssl req \ | 43 try openssl req \ |
42 -new \ | 44 -new \ |
43 -keyout out/expired_cert.key \ | 45 -keyout out/expired_cert.key \ |
44 -out out/expired_cert.req \ | 46 -out out/expired_cert.req \ |
45 -config ee.cnf | 47 -config ee.cnf |
46 | 48 |
47 try openssl req \ | 49 try openssl req \ |
48 -new \ | 50 -new \ |
49 -keyout out/ok_cert.key \ | 51 -keyout out/ok_cert.key \ |
50 -out out/ok_cert.req \ | 52 -out out/ok_cert.req \ |
51 -config ee.cnf | 53 -config ee.cnf |
52 | 54 |
53 SUBJECT_NAME=req_localhost_cn \ | |
54 try openssl req \ | |
55 -new \ | |
56 -keyout out/localhost_cert.key \ | |
57 -out out/localhost_cert.req \ | |
58 -reqexts req_localhost_san \ | |
59 -config ee.cnf | |
60 | |
61 # Generate the leaf certificates | 55 # Generate the leaf certificates |
62 CA_COMMON_NAME="Test Root CA" \ | 56 CA_COMMON_NAME="Test Root CA" \ |
63 try openssl ca \ | 57 try openssl ca \ |
64 -batch \ | 58 -batch \ |
65 -extensions user_cert \ | 59 -extensions user_cert \ |
66 -startdate 060101000000Z \ | 60 -startdate 060101000000Z \ |
67 -enddate 070101000000Z \ | 61 -enddate 070101000000Z \ |
68 -in out/expired_cert.req \ | 62 -in out/expired_cert.req \ |
69 -out out/expired_cert.pem \ | 63 -out out/expired_cert.pem \ |
70 -config ca.cnf | 64 -config ca.cnf |
(...skipping 20 matching lines...) Expand all Loading... |
91 CA_COMMON_NAME="Test Root CA" \ | 85 CA_COMMON_NAME="Test Root CA" \ |
92 try openssl ca \ | 86 try openssl ca \ |
93 -batch \ | 87 -batch \ |
94 -extensions name_constraint_good \ | 88 -extensions name_constraint_good \ |
95 -subj "/CN=Leaf Certificate/" \ | 89 -subj "/CN=Leaf Certificate/" \ |
96 -days 3650 \ | 90 -days 3650 \ |
97 -in out/ok_cert.req \ | 91 -in out/ok_cert.req \ |
98 -out out/name_constraint_good.pem \ | 92 -out out/name_constraint_good.pem \ |
99 -config ca.cnf | 93 -config ca.cnf |
100 | 94 |
101 CA_COMMON_NAME="Test Root CA" \ | |
102 try openssl ca \ | |
103 -batch \ | |
104 -extensions user_cert \ | |
105 -days 3650 \ | |
106 -in out/localhost_cert.req \ | |
107 -out out/localhost_cert.pem \ | |
108 -config ca.cnf | |
109 | |
110 try /bin/sh -c "cat out/ok_cert.key out/ok_cert.pem \ | 95 try /bin/sh -c "cat out/ok_cert.key out/ok_cert.pem \ |
111 > ../certificates/ok_cert.pem" | 96 > ../certificates/ok_cert.pem" |
112 try /bin/sh -c "cat out/localhost_cert.key out/localhost_cert.pem \ | |
113 > ../certificates/localhost_cert.pem" | |
114 try /bin/sh -c "cat out/expired_cert.key out/expired_cert.pem \ | 97 try /bin/sh -c "cat out/expired_cert.key out/expired_cert.pem \ |
115 > ../certificates/expired_cert.pem" | 98 > ../certificates/expired_cert.pem" |
116 try /bin/sh -c "cat out/2048-sha256-root.key out/2048-sha256-root.pem \ | 99 try /bin/sh -c "cat out/2048-sha256-root.key out/2048-sha256-root.pem \ |
117 > ../certificates/root_ca_cert.pem" | 100 > ../certificates/root_ca_cert.pem" |
118 try /bin/sh -c "cat out/ok_cert.key out/name_constraint_bad.pem \ | 101 try /bin/sh -c "cat out/ok_cert.key out/name_constraint_bad.pem \ |
119 > ../certificates/name_constraint_bad.pem" | 102 > ../certificates/name_constraint_bad.pem" |
120 try /bin/sh -c "cat out/ok_cert.key out/name_constraint_good.pem \ | 103 try /bin/sh -c "cat out/ok_cert.key out/name_constraint_good.pem \ |
121 > ../certificates/name_constraint_good.pem" | 104 > ../certificates/name_constraint_good.pem" |
122 | 105 |
123 # Now generate the one-off certs | 106 # Now generate the one-off certs |
124 ## SHA-256 general test cert | 107 ## SHA-256 general test cert |
125 try openssl req -x509 -days 3650 \ | 108 try openssl req -x509 -days 3650 \ |
126 -config ../scripts/ee.cnf -newkey rsa:2048 -text \ | 109 -config ../scripts/ee.cnf -newkey rsa:2048 -text \ |
127 -sha256 \ | 110 -sha256 \ |
128 -out ../certificates/sha256.pem | 111 -out sha256.pem |
129 | 112 |
130 ## Self-signed cert for SPDY/QUIC/HTTP2 pooling testing | 113 ## Self-signed cert for SPDY/QUIC/HTTP2 pooling testing |
131 try openssl req -x509 -days 3650 -extensions req_spdy_pooling \ | 114 try openssl req -x509 -days 3650 -extensions req_spdy_pooling \ |
132 -config ../scripts/ee.cnf -newkey rsa:2048 -text \ | 115 -config ../scripts/ee.cnf -newkey rsa:2048 -text \ |
133 -out ../certificates/spdy_pooling.pem | 116 -out ../certificates/spdy_pooling.pem |
134 | 117 |
135 ## SubjectAltName parsing | 118 ## SubjectAltName parsing |
136 try openssl req -x509 -days 3650 -extensions req_san_sanity \ | 119 try openssl req -x509 -days 3650 -extensions req_san_sanity \ |
137 -config ../scripts/ee.cnf -newkey rsa:2048 -text \ | 120 -config ../scripts/ee.cnf -newkey rsa:2048 -text \ |
138 -out ../certificates/subjectAltName_sanity_check.pem | 121 -out ../certificates/subjectAltName_sanity_check.pem |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 ## Block a leaf cert by issuer-hash-and-serial. However, this will be issued | 282 ## Block a leaf cert by issuer-hash-and-serial. However, this will be issued |
300 ## from an intermediate CA issued underneath a root. | 283 ## from an intermediate CA issued underneath a root. |
301 try python crlsetutil.py -o ../certificates/crlset_by_intermediate_serial.raw \ | 284 try python crlsetutil.py -o ../certificates/crlset_by_intermediate_serial.raw \ |
302 <<CRLSETBYINTERMEDIATESERIAL | 285 <<CRLSETBYINTERMEDIATESERIAL |
303 { | 286 { |
304 "BlockedByHash": { | 287 "BlockedByHash": { |
305 "../certificates/quic_intermediate.crt": [3] | 288 "../certificates/quic_intermediate.crt": [3] |
306 } | 289 } |
307 } | 290 } |
308 CRLSETBYINTERMEDIATESERIAL | 291 CRLSETBYINTERMEDIATESERIAL |
OLD | NEW |