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 SHA256 - 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 SHA256 roots
12 # share the same Authority Key ID, Subject Key ID, Subject, and Subject Public
13 # Key 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 SHA256 root.
17 # The SHA256 root should be (temporarily) trusted, and the resulting chain
18 # should be leaf -> SHA256root, not leaf -> MD5root, leaf -> SHA256root ->
19 # MD5root, or leaf -> MD5root -> SHA256root
22 "$@" ||
(e
=$?
; echo "$@" > /dev
/stderr
; exit $e)
28 try
/bin
/sh
-c "echo 01 > out/2048-sha256-root-serial"
29 try
/bin
/sh
-c "echo 02 > out/2048-md5-root-serial"
30 touch out
/2048-sha256-root-index.txt
31 touch out
/2048-md5-root-index.txt
34 try openssl genrsa
-out out
/2048-sha256-root.key
2048
36 # Generate the root certificate
37 CA_COMMON_NAME
="Test Dup-Hash Root CA" \
40 -key out
/2048-sha256-root.key \
41 -out out
/2048-sha256-root.req \
44 CA_COMMON_NAME
="Test Dup-Hash Root CA" \
48 -in out
/2048-sha256-root.req \
49 -out out
/2048-sha256-root.pem \
51 -signkey out
/2048-sha256-root.key \
55 CA_COMMON_NAME
="Test Dup-Hash Root CA" \
59 -in out
/2048-sha256-root.req \
60 -out out
/2048-md5-root.pem \
62 -signkey out
/2048-sha256-root.key \
66 # Generate the leaf certificate request
69 -keyout out
/ok_cert.key \
70 -out out
/ok_cert.req \
73 # Generate the leaf certificates
74 CA_COMMON_NAME
="Test Dup-Hash Root CA" \
77 -extensions user_cert \
80 -out out
/ok_cert.pem \
83 try openssl x509
-text \
84 -in out
/2048-md5-root.pem
> ..
/certificates
/cross-signed-root-md5.pem
85 try openssl x509
-text \
86 -in out
/2048-sha256-root.pem
> ..
/certificates
/cross-signed-root-sha256.pem
87 try openssl x509
-text \
88 -in out
/ok_cert.pem
> ..
/certificates
/cross-signed-leaf.pem