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
5 # found in the LICENSE file.
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.
11 "$@" ||
(e
=$?
; echo "$@" > /dev
/stderr
; exit $e)
17 try
/bin
/sh
-c "echo 01 > out/2048-sha256-root-serial"
18 touch out
/2048-sha256-root-index.txt
21 try openssl genrsa
-out out
/2048-sha256-root.key
2048
23 # Generate the root certificate
24 CA_COMMON_NAME
="Test Root CA" \
27 -key out
/2048-sha256-root.key \
28 -out out
/2048-sha256-root.req \
31 CA_COMMON_NAME
="Test Root CA" \
34 -in out
/2048-sha256-root.req \
35 -signkey out
/2048-sha256-root.key \
38 -text > out
/2048-sha256-root.pem
40 # Generate the leaf certificate requests
43 -keyout out
/expired_cert.key \
44 -out out
/expired_cert.req \
49 -keyout out
/ok_cert.key \
50 -out out
/ok_cert.req \
53 SUBJECT_NAME
=req_localhost_cn \
56 -keyout out
/localhost_cert.key \
57 -out out
/localhost_cert.req \
58 -reqexts req_localhost_san \
61 # Generate the leaf certificates
62 CA_COMMON_NAME
="Test Root CA" \
65 -extensions user_cert \
66 -startdate 060101000000Z \
67 -enddate 070101000000Z \
68 -in out
/expired_cert.req \
69 -out out
/expired_cert.pem \
72 CA_COMMON_NAME
="Test Root CA" \
75 -extensions user_cert \
78 -out out
/ok_cert.pem \
81 CA_COMMON_NAME
="Test Root CA" \
84 -extensions name_constraint_bad \
85 -subj "/CN=Leaf certificate/" \
88 -out out
/name_constraint_bad.pem \
91 CA_COMMON_NAME
="Test Root CA" \
94 -extensions name_constraint_good \
95 -subj "/CN=Leaf Certificate/" \
98 -out out
/name_constraint_good.pem \
101 CA_COMMON_NAME
="Test Root CA" \
104 -extensions user_cert \
106 -in out
/localhost_cert.req \
107 -out out
/localhost_cert.pem \
110 try
/bin
/sh
-c "cat out/ok_cert.key out/ok_cert.pem \
111 > ../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 \
115 > ../certificates/expired_cert.pem"
116 try
/bin
/sh
-c "cat out/2048-sha256-root.key out/2048-sha256-root.pem \
117 > ../certificates/root_ca_cert.pem"
118 try
/bin
/sh
-c "cat out/ok_cert.key out/name_constraint_bad.pem \
119 > ../certificates/name_constraint_bad.pem"
120 try
/bin
/sh
-c "cat out/ok_cert.key out/name_constraint_good.pem \
121 > ../certificates/name_constraint_good.pem"
123 # Now generate the one-off certs
124 ## SHA-256 general test cert
125 try openssl req
-x509 -days 3650 \
126 -config ..
/scripts
/ee.cnf
-newkey rsa
:2048 -text \
128 -out ..
/certificates
/sha256.pem
130 ## Self-signed cert for SPDY/QUIC/HTTP2 pooling testing
131 try openssl req
-x509 -days 3650 -extensions req_spdy_pooling \
132 -config ..
/scripts
/ee.cnf
-newkey rsa
:2048 -text \
133 -out ..
/certificates
/spdy_pooling.pem
135 ## SubjectAltName parsing
136 try openssl req
-x509 -days 3650 -extensions req_san_sanity \
137 -config ..
/scripts
/ee.cnf
-newkey rsa
:2048 -text \
138 -out ..
/certificates
/subjectAltName_sanity_check.pem
141 SUBJECT_NAME
="req_punycode_dn" \
142 try openssl req
-x509 -days 3650 -extensions req_punycode \
143 -config ..
/scripts
/ee.cnf
-newkey rsa
:2048 -text \
144 -out ..
/certificates
/punycodetest.pem
146 ## Reject intranet hostnames in "publicly" trusted certs
148 SUBJECT_NAME
="req_dn" \
149 try openssl req
-x509 -days 1095 \
150 -config ..
/scripts
/ee.cnf
-newkey rsa
:2048 -text \
151 -out ..
/certificates
/reject_intranet_hosts.pem
153 ## Validity too long unit test support.
154 try openssl req
-config ..
/scripts
/ee.cnf \
155 -newkey rsa
:2048 -text -out ..
/certificates
/10_year_validity.req
156 CA_COMMON_NAME
="Test Root CA" \
159 -extensions user_cert \
160 -startdate 081030000000Z \
161 -enddate 181029000000Z \
162 -in ..
/certificates
/10_year_validity.req \
163 -out ..
/certificates
/10_year_validity.pem \
166 try openssl req
-config ..
/scripts
/ee.cnf \
167 -newkey rsa
:2048 -text -out ..
/certificates
/11_year_validity.req
168 CA_COMMON_NAME
="Test Root CA" \
171 -extensions user_cert \
172 -startdate 141030000000Z \
174 -in ..
/certificates
/11_year_validity.req \
175 -out ..
/certificates
/11_year_validity.pem \
177 try openssl req
-config ..
/scripts
/ee.cnf \
178 -newkey rsa
:2048 -text -out ..
/certificates
/39_months_after_2015_04.req
179 CA_COMMON_NAME
="Test Root CA" \
182 -extensions user_cert \
183 -startdate 150402000000Z \
184 -enddate 180702000000Z \
185 -in ..
/certificates
/39_months_after_2015_04.req \
186 -out ..
/certificates
/39_months_after_2015_04.pem \
188 try openssl req
-config ..
/scripts
/ee.cnf \
189 -newkey rsa
:2048 -text -out ..
/certificates
/40_months_after_2015_04.req
190 CA_COMMON_NAME
="Test Root CA" \
193 -extensions user_cert \
194 -startdate 150402000000Z \
195 -enddate 180801000000Z \
196 -in ..
/certificates
/40_months_after_2015_04.req \
197 -out ..
/certificates
/40_months_after_2015_04.pem \
199 try openssl req
-config ..
/scripts
/ee.cnf \
200 -newkey rsa
:2048 -text -out ..
/certificates
/60_months_after_2012_07.req
201 CA_COMMON_NAME
="Test Root CA" \
204 -extensions user_cert \
205 -startdate 141030000000Z \
206 -enddate 190930000000Z \
207 -in ..
/certificates
/60_months_after_2012_07.req \
208 -out ..
/certificates
/60_months_after_2012_07.pem \
210 try openssl req
-config ..
/scripts
/ee.cnf \
211 -newkey rsa
:2048 -text -out ..
/certificates
/61_months_after_2012_07.req
213 CA_COMMON_NAME
="Test Root CA" \
216 -extensions user_cert \
217 -startdate 141030000000Z \
219 -in ..
/certificates
/61_months_after_2012_07.req \
220 -out ..
/certificates
/61_months_after_2012_07.pem \
222 # start date after expiry date
223 try openssl req
-config ..
/scripts
/ee.cnf \
224 -newkey rsa
:2048 -text -out ..
/certificates
/start_after_expiry.req
225 CA_COMMON_NAME
="Test Root CA" \
228 -extensions user_cert \
229 -startdate 180901000000Z \
230 -enddate 150402000000Z \
231 -in ..
/certificates
/start_after_expiry.req \
232 -out ..
/certificates
/start_after_expiry.pem \
234 try openssl req
-config ..
/scripts
/ee.cnf \
235 -newkey rsa
:2048 -text -out ..
/certificates
/start_after_expiry.req
236 # Issued pre-BRs, lifetime < 120 months, expires before 2019-07-01
237 try openssl req
-config ..
/scripts
/ee.cnf \
238 -newkey rsa
:2048 -text -out ..
/certificates
/pre_br_validity_ok.req
239 CA_COMMON_NAME
="Test Root CA" \
242 -extensions user_cert \
243 -startdate 080101000000Z \
244 -enddate 150101000000Z \
245 -in ..
/certificates
/pre_br_validity_ok.req \
246 -out ..
/certificates
/pre_br_validity_ok.pem \
248 try openssl req
-config ..
/scripts
/ee.cnf \
249 -newkey rsa
:2048 -text -out ..
/certificates
/pre_br_validity_ok.req
250 # Issued pre-BRs, lifetime > 120 months, expires before 2019-07-01
251 try openssl req
-config ..
/scripts
/ee.cnf \
252 -newkey rsa
:2048 -text -out ..
/certificates
/pre_br_validity_bad_121.req
253 CA_COMMON_NAME
="Test Root CA" \
256 -extensions user_cert \
257 -startdate 080101000000Z \
258 -enddate 180501000000Z \
259 -in ..
/certificates
/pre_br_validity_bad_121.req \
260 -out ..
/certificates
/pre_br_validity_bad_121.pem \
262 try openssl req
-config ..
/scripts
/ee.cnf \
263 -newkey rsa
:2048 -text -out ..
/certificates
/pre_br_validity_bad_121.req
264 # Issued pre-BRs, lifetime < 120 months, expires after 2019-07-01
265 try openssl req
-config ..
/scripts
/ee.cnf \
266 -newkey rsa
:2048 -text -out ..
/certificates
/pre_br_validity_bad_2020.req
267 CA_COMMON_NAME
="Test Root CA" \
270 -extensions user_cert \
271 -startdate 120501000000Z \
272 -enddate 190703000000Z \
273 -in ..
/certificates
/pre_br_validity_bad_2020.req \
274 -out ..
/certificates
/pre_br_validity_bad_2020.pem \
276 try openssl req
-config ..
/scripts
/ee.cnf \
277 -newkey rsa
:2048 -text -out ..
/certificates
/pre_br_validity_bad_2020.req
280 ## Block a leaf cert directly by SPKI
281 try python crlsetutil.py
-o ..
/certificates
/crlset_by_leaf_spki.raw \
284 "BlockedBySPKI": ["../certificates/ok_cert.pem"]
288 ## Block a leaf cert by issuer-hash-and-serial (ok_cert.pem == serial 2, by
289 ## virtue of the serial file and ordering above.
290 try python crlsetutil.py
-o ..
/certificates
/crlset_by_root_serial.raw \
294 "../certificates/root_ca_cert.pem": [2]
299 ## Block a leaf cert by issuer-hash-and-serial. However, this will be issued
300 ## from an intermediate CA issued underneath a root.
301 try python crlsetutil.py
-o ..
/certificates
/crlset_by_intermediate_serial.raw \
302 <<CRLSETBYINTERMEDIATESERIAL
305 "../certificates/quic_intermediate.crt": [3]
308 CRLSETBYINTERMEDIATESERIAL