3 # Copyright (c) 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 two chains of test certificates:
8 # 1. A1 (end-entity) -> B (self-signed root)
9 # 2. A2 (end-entity) -> B (self-signed root)
11 # In which A1 and A2 share the same key, the same subject common name, but have
12 # distinct O values in their subjects.
14 # This is used to test that NSS can properly generate unique certificate
15 # nicknames for both certificates.
22 generate_key_command
() {
35 echo Create the serial number and index files.
36 try
echo 1 > out
/B-serial
37 try
touch out
/B-index.txt
39 echo Generate the keys.
40 try openssl genrsa
-out out
/A.key
2048
41 try openssl genrsa
-out out
/B.key
2048
43 echo Generate the B CSR.
44 CA_COMMON_NAME
="B Root CA" \
50 TYPE
=B CERTIFICATE
=B \
55 -config redundant-ca.cnf
58 CA_COMMON_NAME
="B Root CA" \
64 -extfile redundant-ca.cnf \
69 echo Generate the A1 end-entity CSR.
70 SUBJECT_NAME
=req_duplicate_cn_1 \
77 echo Generate the A2 end-entity CSR
78 SUBJECT_NAME
=req_duplicate_cn_2 \
87 CA_COMMON_NAME
="B CA" \
92 CERT_TYPE
=intermediate \
93 TYPE
=B CERTIFICATE
=B \
96 -extensions user_cert \
99 -config redundant-ca.cnf
102 CA_COMMON_NAME
="B CA" \
107 CERT_TYPE
=intermediate \
108 TYPE
=B CERTIFICATE
=B \
111 -extensions user_cert \
114 -config redundant-ca.cnf
116 echo Exporting the certificates to PKCS
#12
121 -out ..
/certificates
/duplicate_cn_1.p12 \
128 -out ..
/certificates
/duplicate_cn_2.p12 \
131 cp out
/A1.pem ..
/certificates
/duplicate_cn_1.pem
132 cp out
/A2.pem ..
/certificates
/duplicate_cn_2.pem