3 # Copyright 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 a two roots - one legacy one signed with MD5, and
8 # another (newer) one signed with SHA1 - and has a leaf certificate signed
9 # by these without any distinguishers.
11 # The "cross-signed" comes from the fact that both the MD5 and SHA1 roots share
12 # the same Authority Key ID, Subject Key ID, Subject, and Subject Public Key
13 # Info. When the chain building algorithm is evaluating paths, if it prefers
14 # untrusted over trusted, then it will see the MD5 certificate as a self-signed
15 # cert that is "cross-signed" by the trusted SHA1 root.
17 # The SHA1 root should be (temporarily) trusted, and the resulting chain
18 # should be leaf -> SHA1root, not leaf -> MD5root, leaf -> SHA1root -> MD5root,
19 # or leaf -> MD5root -> SHA1root
29 try
/bin
/sh
-c "echo 01 > out/2048-sha1-root-serial"
30 try
/bin
/sh
-c "echo 02 > out/2048-md5-root-serial"
31 touch out
/2048-sha1-root-index.txt
32 touch out
/2048-md5-root-index.txt
35 try openssl genrsa
-out out
/2048-sha1-root.key
2048
37 # Generate the root certificate
38 CA_COMMON_NAME
="Test Dup-Hash Root CA" \
41 -key out
/2048-sha1-root.key \
42 -out out
/2048-sha1-root.req \
45 CA_COMMON_NAME
="Test Dup-Hash Root CA" \
49 -in out
/2048-sha1-root.req \
50 -out out
/2048-sha1-root.pem \
52 -signkey out
/2048-sha1-root.key \
56 CA_COMMON_NAME
="Test Dup-Hash Root CA" \
60 -in out
/2048-sha1-root.req \
61 -out out
/2048-md5-root.pem \
63 -signkey out
/2048-sha1-root.key \
67 # Generate the leaf certificate request
70 -keyout out
/ok_cert.key \
71 -out out
/ok_cert.req \
74 # Generate the leaf certificates
75 CA_COMMON_NAME
="Test Dup-Hash Root CA" \
78 -extensions user_cert \
81 -out out
/ok_cert.pem \
84 try openssl x509
-text \
85 -in out
/2048-md5-root.pem \
86 -out ..
/certificates
/cross-signed-root-md5.pem
87 try openssl x509
-text \
88 -in out
/2048-sha1-root.pem \
89 -out ..
/certificates
/cross-signed-root-sha1.pem
90 try openssl x509
-text \
92 -out ..
/certificates
/cross-signed-leaf.pem