| OLD | NEW |
| 1 #!/bin/sh | 1 #!/bin/sh |
| 2 | 2 |
| 3 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2014 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 # This script generates two chains of test certificates: |
| 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 |
| 22 try () { | 17 try () { |
| 23 echo "$@" | 18 echo "$@" |
| 24 "$@" || exit 1 | 19 "$@" || exit 1 |
| 25 } | 20 } |
| 26 | 21 |
| 27 try rm -rf out | 22 try rm -rf out |
| 28 try mkdir out | 23 try mkdir out |
| 29 | 24 |
| 30 echo Create the serial number files. | 25 echo Create the serial number files. |
| 31 serial=1000 | 26 serial=1000 |
| 32 for i in B C C2 D | 27 for i in B C C2 D E |
| 33 do | 28 do |
| 34 try /bin/sh -c "echo $serial > out/$i-serial" | 29 try /bin/sh -c "echo $serial > out/$i-serial" |
| 35 serial=$(expr $serial + 1) | 30 serial=$(expr $serial + 1) |
| 36 done | 31 done |
| 37 | 32 |
| 38 echo Generate the keys. | 33 echo Generate the keys. |
| 39 try openssl genrsa -out out/A.key 2048 | 34 try openssl genrsa -out out/A.key 2048 |
| 40 try openssl genrsa -out out/B.key 2048 | 35 try openssl genrsa -out out/B.key 2048 |
| 41 try openssl genrsa -out out/C.key 2048 | 36 try openssl genrsa -out out/C.key 2048 |
| 42 try openssl genrsa -out out/D.key 2048 | 37 try openssl genrsa -out out/D.key 2048 |
| 38 try openssl genrsa -out out/E.key 2048 |
| 43 | 39 |
| 44 echo Generate the D CSR. | 40 echo Generate the D CSR. |
| 45 CA_COMMON_NAME="D Root CA" \ | 41 CA_COMMON_NAME="D Root CA" \ |
| 46 CERTIFICATE=D \ | 42 CERTIFICATE=D \ |
| 47 try openssl req \ | 43 try openssl req \ |
| 48 -new \ | 44 -new \ |
| 49 -key out/D.key \ | 45 -key out/D.key \ |
| 50 -out out/D.csr \ | 46 -out out/D.csr \ |
| 51 -config redundant-ca.cnf | 47 -config redundant-ca.cnf |
| 52 | 48 |
| 53 echo D signs itself. | 49 echo D signs itself. |
| 54 CA_COMMON_NAME="D Root CA" \ | 50 CA_COMMON_NAME="D Root CA" \ |
| 55 try openssl x509 \ | 51 try openssl x509 \ |
| 56 -req -days 3650 \ | 52 -req -days 3650 \ |
| 57 -in out/D.csr \ | 53 -in out/D.csr \ |
| 58 -extensions ca_cert \ | 54 -extensions ca_cert \ |
| 59 -extfile redundant-ca.cnf \ | 55 -extfile redundant-ca.cnf \ |
| 60 -signkey out/D.key \ | 56 -signkey out/D.key \ |
| 61 -out out/D.pem \ | 57 -out out/D.pem \ |
| 62 -text | 58 -text |
| 63 | 59 |
| 64 echo Generate the C2 root CSR. | 60 echo Generate the E CSR. |
| 61 CA_COMMON_NAME="E Root CA" \ |
| 62 CERTIFICATE=E \ |
| 63 try openssl req \ |
| 64 -new \ |
| 65 -key out/E.key \ |
| 66 -out out/E.csr \ |
| 67 -config redundant-ca.cnf |
| 68 |
| 69 echo E signs itself. |
| 70 CA_COMMON_NAME="E Root CA" \ |
| 71 try openssl x509 \ |
| 72 -req -days 3650 \ |
| 73 -in out/E.csr \ |
| 74 -extensions ca_cert \ |
| 75 -extfile redundant-ca.cnf \ |
| 76 -signkey out/E.key \ |
| 77 -out out/E.pem \ |
| 78 -text |
| 79 |
| 80 echo Generate the C2 intermediary CSR. |
| 65 CA_COMMON_NAME="C CA" \ | 81 CA_COMMON_NAME="C CA" \ |
| 66 CERTIFICATE=C2 \ | 82 CERTIFICATE=C2 \ |
| 67 try openssl req \ | 83 try openssl req \ |
| 68 -new \ | 84 -new \ |
| 69 -key out/C.key \ | 85 -key out/C.key \ |
| 70 -out out/C2.csr \ | 86 -out out/C2.csr \ |
| 71 -config redundant-ca.cnf | 87 -config redundant-ca.cnf |
| 72 | 88 |
| 73 echo C2 signs itself. | |
| 74 CA_COMMON_NAME="C CA" \ | |
| 75 try openssl x509 \ | |
| 76 -req -days 3650 \ | |
| 77 -in out/C2.csr \ | |
| 78 -extensions ca_cert \ | |
| 79 -extfile redundant-ca.cnf \ | |
| 80 -signkey out/C.key \ | |
| 81 -out out/C2.pem \ | |
| 82 -text | |
| 83 | |
| 84 echo Generate the B and C intermediaries\' CSRs. | 89 echo Generate the B and C intermediaries\' CSRs. |
| 85 for i in B C | 90 for i in B C |
| 86 do | 91 do |
| 87 name="$i Intermediate CA" | |
| 88 CA_COMMON_NAME="$i CA" \ | 92 CA_COMMON_NAME="$i CA" \ |
| 89 CERTIFICATE=$i \ | 93 CERTIFICATE="$i" \ |
| 90 try openssl req \ | 94 try openssl req \ |
| 91 -new \ | 95 -new \ |
| 92 -key out/$i.key \ | 96 -key "out/$i.key" \ |
| 93 -out out/$i.csr \ | 97 -out "out/$i.csr" \ |
| 94 -config redundant-ca.cnf | 98 -config redundant-ca.cnf |
| 95 done | 99 done |
| 96 | 100 |
| 97 echo D signs the C intermediate. | 101 echo D signs the C intermediate. |
| 98 # Make sure the signer's DB file exists. | 102 # Make sure the signer's DB file exists. |
| 99 touch out/D-index.txt | 103 touch out/D-index.txt |
| 100 CA_COMMON_NAME="D Root CA" \ | 104 CA_COMMON_NAME="D Root CA" \ |
| 101 CERTIFICATE=D \ | 105 CERTIFICATE=D \ |
| 102 try openssl ca \ | 106 try openssl ca \ |
| 103 -batch \ | 107 -batch \ |
| 104 -extensions ca_cert \ | 108 -extensions ca_cert \ |
| 105 -in out/C.csr \ | 109 -in out/C.csr \ |
| 106 -out out/C.pem \ | 110 -out out/C.pem \ |
| 107 -config redundant-ca.cnf | 111 -config redundant-ca.cnf |
| 108 | 112 |
| 113 echo E signs the C2 intermediate. |
| 114 # Make sure the signer's DB file exists. |
| 115 touch out/E-index.txt |
| 116 CA_COMMON_NAME="E Root CA" \ |
| 117 CERTIFICATE=E \ |
| 118 try openssl ca \ |
| 119 -batch \ |
| 120 -extensions ca_cert \ |
| 121 -in out/C2.csr \ |
| 122 -out out/C2.pem \ |
| 123 -config redundant-ca.cnf |
| 124 |
| 109 echo C signs the B intermediate. | 125 echo C signs the B intermediate. |
| 110 touch out/C-index.txt | 126 touch out/C-index.txt |
| 111 CA_COMMON_NAME="C CA" \ | 127 CA_COMMON_NAME="C CA" \ |
| 112 CERTIFICATE=C \ | 128 CERTIFICATE=C \ |
| 113 try openssl ca \ | 129 try openssl ca \ |
| 114 -batch \ | 130 -batch \ |
| 115 -extensions ca_cert \ | 131 -extensions ca_cert \ |
| 116 -in out/B.csr \ | 132 -in out/B.csr \ |
| 117 -out out/B.pem \ | 133 -out out/B.pem \ |
| 118 -config redundant-ca.cnf | 134 -config redundant-ca.cnf |
| 119 | 135 |
| 120 echo Generate the A end-entity CSR. | 136 echo Generate the A end-entity CSR. |
| 121 try openssl req \ | 137 try openssl req \ |
| 122 -new \ | 138 -new \ |
| 123 -key out/A.key \ | 139 -key out/A.key \ |
| 124 -out out/A.csr \ | 140 -out out/A.csr \ |
| 125 -config ee.cnf | 141 -config ee.cnf |
| 126 | 142 |
| 127 echo B signs A. | 143 echo B signs A. |
| 128 touch out/B-index.txt | 144 touch out/B-index.txt |
| 129 CA_COMMON_NAME="B CA" \ | 145 CA_COMMON_NAME="B CA" \ |
| 130 CERTIFICATE=B \ | 146 CERTIFICATE=B \ |
| 131 try openssl ca \ | 147 try openssl ca \ |
| 132 -batch \ | 148 -batch \ |
| 133 -extensions user_cert \ | 149 -extensions user_cert \ |
| 134 -in out/A.csr \ | 150 -in out/A.csr \ |
| 135 -out out/A.pem \ | 151 -out out/A.pem \ |
| 136 -config redundant-ca.cnf | 152 -config redundant-ca.cnf |
| 137 | 153 |
| 138 echo Create redundant-server-chain.pem | 154 echo Create multi-root-chain1.pem |
| 139 try /bin/sh -c "cat out/A.key out/A.pem out/B.pem out/C.pem out/D.pem \ | 155 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" | 156 > ../certificates/multi-root-chain1.pem" |
| 141 | 157 |
| 142 echo Create redundant-validated-chain.pem | 158 echo Create multi-root-chain2.pem |
| 143 try /bin/sh -c "cat out/A.key out/A.pem out/B.pem out/C2.pem \ | 159 try /bin/sh -c "cat out/A.key out/A.pem out/B.pem out/C2.pem out/E.pem \ |
| 144 > ../certificates/redundant-validated-chain.pem" | 160 > ../certificates/multi-root-chain2.pem" |
| 145 | 161 |
| 146 echo Create redundant-validated-chain-root.pem | |
| 147 try cp out/C2.pem ../certificates/redundant-validated-chain-root.pem | |
| 148 | |
| OLD | NEW |