2404N/A#
2469N/A# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
2404N/A# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2404N/A#
2404N/A# This code is free software; you can redistribute it and/or modify it
2404N/A# under the terms of the GNU General Public License version 2 only, as
2404N/A# published by the Free Software Foundation.
2404N/A#
2404N/A# This code is distributed in the hope that it will be useful, but WITHOUT
2404N/A# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
2404N/A# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
2404N/A# version 2 for more details (a copy is included in the LICENSE file that
2404N/A# accompanied this code).
2404N/A#
2404N/A# You should have received a copy of the GNU General Public License version
2404N/A# 2 along with this work; if not, write to the Free Software Foundation,
2404N/A# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
2404N/A#
2469N/A# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2469N/A# or visit www.oracle.com if you need additional information or have any
2469N/A# questions.
2404N/A#
2404N/A
2404N/A# @test
2404N/A# @bug 6948803
2404N/A# @summary CertPath validation regression caused by SHA1 replacement root
2404N/A# and MD2 disable feature
2404N/A#
2404N/A
2404N/Aif [ "${TESTSRC}" = "" ] ; then
2404N/A TESTSRC="."
2404N/Afi
2404N/Aif [ "${TESTJAVA}" = "" ] ; then
2404N/A JAVAC_CMD=`which javac`
2404N/A TESTJAVA=`dirname $JAVAC_CMD`/..
2404N/Afi
2404N/A
2404N/A# set platform-dependent variables
2404N/AOS=`uname -s`
2404N/Acase "$OS" in
2404N/A Windows_* )
2404N/A FS="\\"
2404N/A ;;
2404N/A * )
2404N/A FS="/"
2404N/A ;;
2404N/Aesac
2404N/A
2404N/AKT="$TESTJAVA${FS}bin${FS}keytool -storepass changeit \
2404N/A -keypass changeit -keystore certreplace.jks"
2404N/AJAVAC=$TESTJAVA${FS}bin${FS}javac
2404N/AJAVA=$TESTJAVA${FS}bin${FS}java
2404N/A
2404N/Arm -rf certreplace.jks 2> /dev/null
2404N/A
2404N/A# 1. Generate 3 aliases in a keystore: ca, int, user
2404N/A
2404N/A$KT -genkeypair -alias ca -dname CN=CA -keyalg rsa -sigalg md2withrsa -ext bc
2404N/A$KT -genkeypair -alias int -dname CN=Int -keyalg rsa
2404N/A$KT -genkeypair -alias user -dname CN=User -keyalg rsa
2404N/A
2404N/A# 2. Signing: ca -> int -> user
2404N/A
2404N/A$KT -certreq -alias int | $KT -gencert -rfc -alias ca -ext bc \
2404N/A | $KT -import -alias int
2404N/A$KT -certreq -alias user | $KT -gencert -rfc -alias int \
2404N/A | $KT -import -alias user
2404N/A
2404N/A# 3. Create the certchain file
2404N/A
2404N/A$KT -export -alias user -rfc > certreplace.certs
2404N/A$KT -export -rfc -alias int >> certreplace.certs
2404N/A$KT -export -rfc -alias ca >> certreplace.certs
2404N/A
2404N/A# 4. Upgrade ca from MD2withRSA to SHA256withRSA, remove other aliases and
2404N/A# make this keystore the cacerts file
2404N/A
2404N/A$KT -selfcert -alias ca
2404N/A$KT -delete -alias int
2404N/A$KT -delete -alias user
2404N/A
2404N/A# 5. Build and run test
2404N/A
2404N/A$JAVAC -d . ${TESTSRC}${FS}CertReplace.java
2469N/A$JAVA CertReplace certreplace.jks certreplace.certs