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

Side by Side Diff: net/data/ssl/scripts/generate-foo-test-chains.sh

Issue 137553004: NSS Cros multiprofile: trust roots added by a profile shouldn't apply to other profiles. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: handle additional trust roots, add TestRootCertsTest.Contains, remove instantiated certtests from c… Created 6 years, 10 months 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 | Annotate | Revision Log
OLDNEW
1 #!/bin/sh 1 #!/bin/sh
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 two chains of test certificates: 7 # XXX This script generates two chains of test certificates:
Ryan Sleevi 2014/01/30 05:27:40 XXX ?
mattm 2014/02/04 05:31:21 Done.
8 # 8 #
9 # 1. A (end-entity) -> B -> C -> D (self-signed root) 9 # 1. A (end-entity) -> B -> C -> D (self-signed root)
10 # 2. A (end-entity) -> B -> C2 (self-signed root) 10 # 2. A (end-entity) -> B -> C2 -> E (self-signed root)
11 # 11 #
12 # in which A, B, C, and D have distinct keypairs. C2 is a self-signed root 12 # C and C2 have the same subject and keypair.
13 # certificate that uses the same keypair as C.
14 # 13 #
15 # We use these cert chains in 14 # We use these cert chains in CertVerifyProcChromeOSTest
16 # SSLClientSocketTest.VerifyReturnChainProperlyOrdered to ensure that 15 # to ensure that multiple verification paths are properly handled.
17 # SSLInfo objects see the certificate chain as validated rather than as
18 # served by the server. The server serves chain 1. The client has C2, NOT D,
19 # installed as a trusted root. Therefore, the chain will validate as chain
20 # 2, even though the server served chain 1.
21 16
17 set -x
22 try () { 18 try () {
23 echo "$@" 19 echo "$@"
24 $@ || exit 1 20 $@ || exit 1
25 } 21 }
26 22
27 generate_key_command () {
28 case "$1" in
29 rsa)
30 echo genrsa
31 ;;
32 *)
33 exit 1
34 esac
35 }
36
37 try rm -rf out 23 try rm -rf out
38 try mkdir out 24 try mkdir out
39 25
40 echo Create the serial number files. 26 echo Create the serial number files.
41 serial=100 27 serial=1000
42 for i in B C C2 D 28 for i in B C C2 D E
43 do 29 do
44 try echo $serial > out/$i-serial 30 echo $serial > out/$i-serial
45 serial=$(expr $serial + 1) 31 serial=$(expr $serial + 1)
46 done 32 done
47 33
48 echo Generate the keys. 34 echo Generate the keys.
49 try openssl genrsa -out out/A.key 2048 35 try openssl genrsa -out out/A.key 2048
50 try openssl genrsa -out out/B.key 2048 36 try openssl genrsa -out out/B.key 2048
51 try openssl genrsa -out out/C.key 2048 37 try openssl genrsa -out out/C.key 2048
52 try openssl genrsa -out out/D.key 2048 38 try openssl genrsa -out out/D.key 2048
39 try openssl genrsa -out out/E.key 2048
53 40
54 echo Generate the D CSR. 41 echo Generate the D CSR.
55 CA_COMMON_NAME="D Root CA" \ 42 CA_COMMON_NAME="D Root CA" \
56 CA_DIR=out \ 43 CA_DIR=out \
57 CA_NAME=req_env_dn \ 44 CA_NAME=req_env_dn \
58 KEY_SIZE=2048 \ 45 KEY_SIZE=2048 \
59 ALGO=rsa \ 46 ALGO=rsa \
60 CERT_TYPE=root \ 47 CERT_TYPE=root \
61 TYPE=D CERTIFICATE=D \ 48 TYPE=D CERTIFICATE=D \
62 try openssl req \ 49 try openssl req \
63 -new \ 50 -new \
64 -key out/D.key \ 51 -key out/D.key \
65 -out out/D.csr \ 52 -out out/D.csr \
66 -config redundant-ca.cnf 53 -config redundant-ca.cnf
67 54
68 echo D signs itself. 55 echo D signs itself.
69 CA_COMMON_NAME="D Root CA" \ 56 CA_COMMON_NAME="D Root CA" \
70 CA_DIR=out \ 57 CA_DIR=out \
71 CA_NAME=req_env_dn \ 58 CA_NAME=req_env_dn \
72 try openssl x509 \ 59 try openssl x509 \
73 -req -days 3650 \ 60 -req -days 3650 \
74 -in out/D.csr \ 61 -in out/D.csr \
75 -extensions ca_cert \ 62 -extensions ca_cert \
76 -signkey out/D.key \ 63 -signkey out/D.key \
77 -out out/D.pem 64 -out out/D.pem
78 65
79 echo Generate the C2 root CSR. 66 echo Generate the E CSR.
67 CA_COMMON_NAME="E Root CA" \
68 CA_DIR=out \
69 CA_NAME=req_env_dn \
70 KEY_SIZE=2048 \
71 ALGO=rsa \
72 CERT_TYPE=root \
73 TYPE=E CERTIFICATE=E \
74 try openssl req \
75 -new \
76 -key out/E.key \
77 -out out/E.csr \
78 -config redundant-ca.cnf
79
80 echo E signs itself.
81 CA_COMMON_NAME="E Root CA" \
82 CA_DIR=out \
83 CA_NAME=req_env_dn \
84 try openssl x509 \
85 -req -days 3650 \
86 -in out/E.csr \
87 -extensions ca_cert \
88 -signkey out/E.key \
89 -out out/E.pem
90
91 echo Generate the C2 intermediary CSR.
80 CA_COMMON_NAME="C CA" \ 92 CA_COMMON_NAME="C CA" \
81 CA_DIR=out \ 93 CA_DIR=out \
82 CA_NAME=req_env_dn \ 94 CA_NAME=req_env_dn \
83 KEY_SIZE=2048 \ 95 KEY_SIZE=2048 \
84 ALGO=rsa \ 96 ALGO=rsa \
85 CERT_TYPE=root \ 97 CERT_TYPE=root \
86 TYPE=C2 CERTIFICATE=C2 \ 98 TYPE=C2 CERTIFICATE=C2 \
87 try openssl req \ 99 try openssl req \
88 -new \ 100 -new \
89 -key out/C.key \ 101 -key out/C.key \
90 -out out/C2.csr \ 102 -out out/C2.csr \
91 -config redundant-ca.cnf 103 -config redundant-ca.cnf
92 104
93 echo C2 signs itself.
94 CA_COMMON_NAME="C CA" \
95 CA_DIR=out \
96 CA_NAME=req_env_dn \
97 try openssl x509 \
98 -req -days 3650 \
99 -in out/C2.csr \
100 -extensions ca_cert \
101 -signkey out/C.key \
102 -out out/C2.pem
103
104 echo Generate the B and C intermediaries\' CSRs. 105 echo Generate the B and C intermediaries\' CSRs.
105 for i in B C 106 for i in B C
106 do 107 do
107 name="$i Intermediate CA"
108 CA_COMMON_NAME="$i CA" \ 108 CA_COMMON_NAME="$i CA" \
109 CA_DIR=out \ 109 CA_DIR=out \
110 CA_NAME=req_env_dn \ 110 CA_NAME=req_env_dn \
111 KEY_SIZE=2048 \ 111 KEY_SIZE=2048 \
112 ALGO=rsa \ 112 ALGO=rsa \
113 CERT_TYPE=root \ 113 CERT_TYPE=root \
114 TYPE=$i CERTIFICATE=$i \ 114 TYPE=$i CERTIFICATE=$i \
115 try openssl req \ 115 try openssl req \
116 -new \ 116 -new \
117 -key out/$i.key \ 117 -key out/$i.key \
(...skipping 11 matching lines...) Expand all
129 ALGO=rsa \ 129 ALGO=rsa \
130 CERT_TYPE=root \ 130 CERT_TYPE=root \
131 TYPE=D CERTIFICATE=D \ 131 TYPE=D CERTIFICATE=D \
132 try openssl ca \ 132 try openssl ca \
133 -batch \ 133 -batch \
134 -extensions ca_cert \ 134 -extensions ca_cert \
135 -in out/C.csr \ 135 -in out/C.csr \
136 -out out/C.pem \ 136 -out out/C.pem \
137 -config redundant-ca.cnf 137 -config redundant-ca.cnf
138 138
139 echo E signs the C2 intermediate.
140 # Make sure the signer's DB file exists.
141 touch out/E-index.txt
142 CA_COMMON_NAME="E Root CA" \
143 CA_DIR=out \
144 CA_NAME=req_env_dn \
145 KEY_SIZE=2048 \
146 ALGO=rsa \
147 CERT_TYPE=root \
148 TYPE=E CERTIFICATE=E \
149 try openssl ca \
150 -batch \
151 -extensions ca_cert \
152 -in out/C2.csr \
153 -out out/C2.pem \
154 -config redundant-ca.cnf
155
139 echo C signs the B intermediate. 156 echo C signs the B intermediate.
140 touch out/C-index.txt 157 touch out/C-index.txt
141 CA_COMMON_NAME="C CA" \ 158 CA_COMMON_NAME="C CA" \
142 CA_DIR=out \ 159 CA_DIR=out \
143 CA_NAME=req_env_dn \ 160 CA_NAME=req_env_dn \
144 KEY_SIZE=2048 \ 161 KEY_SIZE=2048 \
145 ALGO=rsa \ 162 ALGO=rsa \
146 CERT_TYPE=root \ 163 CERT_TYPE=root \
147 TYPE=C CERTIFICATE=C \ 164 TYPE=C CERTIFICATE=C \
148 try openssl ca \ 165 try openssl ca \
(...skipping 19 matching lines...) Expand all
168 ALGO=$signer_algo \ 185 ALGO=$signer_algo \
169 CERT_TYPE=intermediate \ 186 CERT_TYPE=intermediate \
170 TYPE=B CERTIFICATE=B \ 187 TYPE=B CERTIFICATE=B \
171 try openssl ca \ 188 try openssl ca \
172 -batch \ 189 -batch \
173 -extensions user_cert \ 190 -extensions user_cert \
174 -in out/A.csr \ 191 -in out/A.csr \
175 -out out/A.pem \ 192 -out out/A.pem \
176 -config redundant-ca.cnf 193 -config redundant-ca.cnf
177 194
178 echo Create redundant-server-chain.pem 195 echo Create foo-chain1.pem
179 cat out/A.key out/A.pem out/B.pem out/C.pem out/D.pem \ 196 cat out/A.key out/A.pem out/B.pem out/C.pem out/D.pem \
180 > redundant-server-chain.pem 197 > foo-chain1.pem
Ryan Sleevi 2014/01/30 05:27:40 naming: better name than "foo"
mattm 2014/02/04 05:31:21 Done.
181 198
182 echo Create redundant-validated-chain.pem 199 echo Create foo-chain2.pem
183 cat out/A.key out/A.pem out/B.pem out/C2.pem > redundant-validated-chain.pem 200 cat out/A.key out/A.pem out/B.pem out/C2.pem out/E.pem \
201 > foo-chain2.pem
184 202
185 echo Create redundant-validated-chain-root.pem
186 cp out/C2.pem redundant-validated-chain-root.pem
187
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698