Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(203)

Side by Side Diff: net/data/ssl/scripts/generate-client-certificates.sh

Issue 2567523003: Fix P-521 client cert mapping and test all curves. (Closed)
Patch Set: reupload with hack to depot_tools Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/data/ssl/certificates/client_root_ca.pem ('k') | net/net.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/bin/bash 1 #!/bin/bash
2 2
3 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 3 # Copyright (c) 2012 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 certificates that can be used to test SSL client 7 # This script generates certificates that can be used to test SSL client
8 # authentication. Outputs for automated tests are stored in 8 # authentication. Outputs for automated tests are stored in
9 # net/data/ssl/certificates, but may be re-generated for manual testing. 9 # net/data/ssl/certificates, but may be re-generated for manual testing.
10 # 10 #
11 # This script generates several chains of test client certificates: 11 # This script generates several chains of test client certificates:
12 # 12 #
13 # 1. A (end-entity) -> B -> C (self-signed root) 13 # 1. A (end-entity) -> B -> C (self-signed root)
14 # 2. D (end-entity) -> E -> C (self-signed root) 14 # 2. D (end-entity) -> E -> C (self-signed root)
15 # 3. F (end-entity) -> E -> C (self-signed root) 15 # 3. F (end-entity) -> E -> C (self-signed root)
16 # 4. G (end-entity, P-256) -> E -> C (self-signed root) 16 # 4. G (end-entity, P-256) -> E -> C (self-signed root)
17 # 5. H (end-entity, P-384) -> E -> C (self-signed root)
18 # 6. I (end-entity, P-521) -> E -> C (self-signed root)
17 # 19 #
18 # In which the certificates all have distinct keypairs. The client 20 # In which the certificates all have distinct keypairs. The client
19 # certificates share the same root, but are issued by different 21 # certificates share the same root, but are issued by different
20 # intermediates. The names of these intermediates are hardcoded within 22 # intermediates. The names of these intermediates are hardcoded within
21 # unit tests, and thus should not be changed. 23 # unit tests, and thus should not be changed.
22 24
23 try () { 25 try () {
24 echo "$@" 26 echo "$@"
25 "$@" || exit 1 27 "$@" || exit 1
26 } 28 }
(...skipping 11 matching lines...) Expand all
38 touch out/$i-index.txt.attr 40 touch out/$i-index.txt.attr
39 done 41 done
40 42
41 echo Generate the keys. 43 echo Generate the keys.
42 for i in A B C D E F 44 for i in A B C D E F
43 do 45 do
44 try openssl genrsa -out out/$i.key 2048 46 try openssl genrsa -out out/$i.key 2048
45 done 47 done
46 48
47 try openssl ecparam -name prime256v1 -genkey -noout -out out/G.key 49 try openssl ecparam -name prime256v1 -genkey -noout -out out/G.key
50 try openssl ecparam -name secp384r1 -genkey -noout -out out/H.key
51 try openssl ecparam -name secp521r1 -genkey -noout -out out/I.key
48 52
49 echo Generate the C CSR 53 echo Generate the C CSR
50 COMMON_NAME="C Root CA" \ 54 COMMON_NAME="C Root CA" \
51 CA_DIR=out \ 55 CA_DIR=out \
52 ID=C \ 56 ID=C \
53 try openssl req \ 57 try openssl req \
54 -new \ 58 -new \
55 -key out/C.key \ 59 -key out/C.key \
56 -out out/C.csr \ 60 -out out/C.csr \
57 -config client-certs.cnf 61 -config client-certs.cnf
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 CA_DIR=out \ 105 CA_DIR=out \
102 ID=C \ 106 ID=C \
103 try openssl ca \ 107 try openssl ca \
104 -batch \ 108 -batch \
105 -extensions ca_cert \ 109 -extensions ca_cert \
106 -in out/E.csr \ 110 -in out/E.csr \
107 -out out/E.pem \ 111 -out out/E.pem \
108 -config client-certs.cnf 112 -config client-certs.cnf
109 113
110 echo Generate the leaf certs 114 echo Generate the leaf certs
111 for id in A D F G 115 for id in A D F G H I
112 do 116 do
113 COMMON_NAME="Client Cert $id" \ 117 COMMON_NAME="Client Cert $id" \
114 ID=$id \ 118 ID=$id \
115 try openssl req \ 119 try openssl req \
116 -new \ 120 -new \
117 -key out/$id.key \ 121 -key out/$id.key \
118 -out out/$id.csr \ 122 -out out/$id.csr \
119 -config client-certs.cnf 123 -config client-certs.cnf
120 # Store the private key also in PKCS#8 format. 124 # Store the private key also in PKCS#8 format.
121 try openssl pkcs8 \ 125 try openssl pkcs8 \
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 COMMON_NAME="E CA" \ 166 COMMON_NAME="E CA" \
163 CA_DIR=out \ 167 CA_DIR=out \
164 ID=E \ 168 ID=E \
165 try openssl ca \ 169 try openssl ca \
166 -batch \ 170 -batch \
167 -extensions user_cert \ 171 -extensions user_cert \
168 -in out/G.csr \ 172 -in out/G.csr \
169 -out out/G.pem \ 173 -out out/G.pem \
170 -config client-certs.cnf 174 -config client-certs.cnf
171 175
176 echo E signs H
177 COMMON_NAME="E CA" \
178 CA_DIR=out \
179 ID=E \
180 try openssl ca \
181 -batch \
182 -extensions user_cert \
183 -in out/H.csr \
184 -out out/H.pem \
185 -config client-certs.cnf
186
187 echo E signs I
188 COMMON_NAME="E CA" \
189 CA_DIR=out \
190 ID=E \
191 try openssl ca \
192 -batch \
193 -extensions user_cert \
194 -in out/I.csr \
195 -out out/I.pem \
196 -config client-certs.cnf
197
172 echo Package the client certs and private keys into PKCS12 files 198 echo Package the client certs and private keys into PKCS12 files
173 # This is done for easily importing all of the certs needed for clients. 199 # This is done for easily importing all of the certs needed for clients.
174 try /bin/sh -c "cat out/A.pem out/A.key out/B.pem out/C.pem > out/A-chain.pem" 200 try /bin/sh -c "cat out/A.pem out/A.key out/B.pem out/C.pem > out/A-chain.pem"
175 try /bin/sh -c "cat out/D.pem out/D.key out/E.pem out/C.pem > out/D-chain.pem" 201 try /bin/sh -c "cat out/D.pem out/D.key out/E.pem out/C.pem > out/D-chain.pem"
176 try /bin/sh -c "cat out/F.pem out/F.key out/E.pem out/C.pem > out/F-chain.pem" 202 try /bin/sh -c "cat out/F.pem out/F.key out/E.pem out/C.pem > out/F-chain.pem"
177 try /bin/sh -c "cat out/G.pem out/G.key out/E.pem out/C.pem > out/G-chain.pem" 203 try /bin/sh -c "cat out/G.pem out/G.key out/E.pem out/C.pem > out/G-chain.pem"
204 try /bin/sh -c "cat out/H.pem out/H.key out/E.pem out/C.pem > out/H-chain.pem"
205 try /bin/sh -c "cat out/I.pem out/I.key out/E.pem out/C.pem > out/I-chain.pem"
178 206
179 try openssl pkcs12 \ 207 try openssl pkcs12 \
180 -in out/A-chain.pem \ 208 -in out/A-chain.pem \
181 -out client_1.p12 \ 209 -out client_1.p12 \
182 -export \ 210 -export \
183 -passout pass:chrome 211 -passout pass:chrome
184 212
185 try openssl pkcs12 \ 213 try openssl pkcs12 \
186 -in out/D-chain.pem \ 214 -in out/D-chain.pem \
187 -out client_2.p12 \ 215 -out client_2.p12 \
188 -export \ 216 -export \
189 -passout pass:chrome 217 -passout pass:chrome
190 218
191 try openssl pkcs12 \ 219 try openssl pkcs12 \
192 -in out/F-chain.pem \ 220 -in out/F-chain.pem \
193 -out client_3.p12 \ 221 -out client_3.p12 \
194 -export \ 222 -export \
195 -passout pass:chrome 223 -passout pass:chrome
196 224
197 try openssl pkcs12 \ 225 try openssl pkcs12 \
198 -in out/G-chain.pem \ 226 -in out/G-chain.pem \
199 -out client_4.p12 \ 227 -out client_4.p12 \
200 -export \ 228 -export \
201 -passout pass:chrome 229 -passout pass:chrome
202 230
231 try openssl pkcs12 \
232 -in out/H-chain.pem \
233 -out client_5.p12 \
234 -export \
235 -passout pass:chrome
236
237 try openssl pkcs12 \
238 -in out/I-chain.pem \
239 -out client_6.p12 \
240 -export \
241 -passout pass:chrome
242
203 echo Package the client certs for unit tests 243 echo Package the client certs for unit tests
204 try cp out/A.pem ../certificates/client_1.pem 244 try cp out/A.pem ../certificates/client_1.pem
205 try cp out/A.key ../certificates/client_1.key 245 try cp out/A.key ../certificates/client_1.key
206 try cp out/A.pk8 ../certificates/client_1.pk8 246 try cp out/A.pk8 ../certificates/client_1.pk8
207 try cp out/B.pem ../certificates/client_1_ca.pem 247 try cp out/B.pem ../certificates/client_1_ca.pem
208 248
209 try cp out/D.pem ../certificates/client_2.pem 249 try cp out/D.pem ../certificates/client_2.pem
210 try cp out/D.key ../certificates/client_2.key 250 try cp out/D.key ../certificates/client_2.key
211 try cp out/D.pk8 ../certificates/client_2.pk8 251 try cp out/D.pk8 ../certificates/client_2.pk8
212 try cp out/E.pem ../certificates/client_2_ca.pem 252 try cp out/E.pem ../certificates/client_2_ca.pem
213 253
214 try cp out/F.pem ../certificates/client_3.pem 254 try cp out/F.pem ../certificates/client_3.pem
215 try cp out/F.key ../certificates/client_3.key 255 try cp out/F.key ../certificates/client_3.key
216 try cp out/F.pk8 ../certificates/client_3.pk8 256 try cp out/F.pk8 ../certificates/client_3.pk8
217 try cp out/E.pem ../certificates/client_3_ca.pem 257 try cp out/E.pem ../certificates/client_3_ca.pem
218 258
219 try cp out/G.pem ../certificates/client_4.pem 259 try cp out/G.pem ../certificates/client_4.pem
220 try cp out/G.key ../certificates/client_4.key 260 try cp out/G.key ../certificates/client_4.key
221 try cp out/G.pk8 ../certificates/client_4.pk8 261 try cp out/G.pk8 ../certificates/client_4.pk8
222 try cp out/E.pem ../certificates/client_4_ca.pem 262 try cp out/E.pem ../certificates/client_4_ca.pem
223 263
264 try cp out/H.pem ../certificates/client_5.pem
265 try cp out/H.key ../certificates/client_5.key
266 try cp out/H.pk8 ../certificates/client_5.pk8
267 try cp out/E.pem ../certificates/client_5_ca.pem
268
269 try cp out/I.pem ../certificates/client_6.pem
270 try cp out/I.key ../certificates/client_6.key
271 try cp out/I.pk8 ../certificates/client_6.pk8
272 try cp out/E.pem ../certificates/client_6_ca.pem
273
224 try cp out/C.pem ../certificates/client_root_ca.pem 274 try cp out/C.pem ../certificates/client_root_ca.pem
OLDNEW
« no previous file with comments | « net/data/ssl/certificates/client_root_ca.pem ('k') | net/net.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698