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
5 # found in the LICENSE file.
7 # This script generates two chains of test certificates:
9 # 1. A (end-entity) -> B -> C -> D (self-signed root)
10 # 2. A (end-entity) -> B -> C2 (self-signed root)
12 # in which A, B, C, and D have distinct keypairs. C2 is a self-signed root
13 # certificate that uses the same keypair as C.
15 # We use these cert chains in
16 # SSLClientSocketTest.VerifyReturnChainProperlyOrdered to ensure that
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.
30 echo Create the serial number files.
34 try
/bin
/sh
-c "echo $serial > out/$i-serial"
35 serial
=$
(expr $serial + 1)
38 echo Generate the keys.
39 try openssl genrsa
-out out
/A.key
2048
40 try openssl genrsa
-out out
/B.key
2048
41 try openssl genrsa
-out out
/C.key
2048
42 try openssl genrsa
-out out
/D.key
2048
44 echo Generate the D CSR.
45 CA_COMMON_NAME
="D Root CA" \
51 -config redundant-ca.cnf
54 CA_COMMON_NAME
="D Root CA" \
59 -extfile redundant-ca.cnf \
64 echo Generate the C2 root CSR.
65 CA_COMMON_NAME
="C CA" \
71 -config redundant-ca.cnf
74 CA_COMMON_NAME
="C CA" \
79 -extfile redundant-ca.cnf \
84 echo Generate the B and C intermediaries
\' CSRs.
87 name
="$i Intermediate CA"
88 CA_COMMON_NAME
="$i CA" \
94 -config redundant-ca.cnf
97 echo D signs the C intermediate.
98 # Make sure the signer's DB file exists.
100 CA_COMMON_NAME
="D Root CA" \
104 -extensions ca_cert \
107 -config redundant-ca.cnf
109 echo C signs the B intermediate.
110 touch out
/C-index.txt
111 CA_COMMON_NAME
="C CA" \
115 -extensions ca_cert \
118 -config redundant-ca.cnf
120 echo Generate the A end-entity CSR.
128 touch out
/B-index.txt
129 CA_COMMON_NAME
="B CA" \
133 -extensions user_cert \
136 -config redundant-ca.cnf
138 echo Create redundant-server-chain.pem
139 try
/bin
/sh
-c "cat out/A.key out/A.pem out/B.pem out/C.pem out/D.pem \
140 > ../certificates/redundant-server-chain.pem"
142 echo Create redundant-validated-chain.pem
143 try
/bin
/sh
-c "cat out/A.key out/A.pem out/B.pem out/C2.pem \
144 > ../certificates/redundant-validated-chain.pem"
146 echo Create redundant-validated-chain-root.pem
147 try
cp out
/C2.pem ..
/certificates
/redundant-validated-chain-root.pem