Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/sun/security/validator/certreplace.sh
38839 views
#1# Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.2# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3#4# This code is free software; you can redistribute it and/or modify it5# under the terms of the GNU General Public License version 2 only, as6# published by the Free Software Foundation.7#8# This code is distributed in the hope that it will be useful, but WITHOUT9# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11# version 2 for more details (a copy is included in the LICENSE file that12# accompanied this code).13#14# You should have received a copy of the GNU General Public License version15# 2 along with this work; if not, write to the Free Software Foundation,16# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17#18# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19# or visit www.oracle.com if you need additional information or have any20# questions.21#2223# @test24# @bug 694880325# @summary CertPath validation regression caused by SHA1 replacement root26# and MD2 disable feature27#2829if [ "${TESTSRC}" = "" ] ; then30TESTSRC="."31fi32if [ "${TESTJAVA}" = "" ] ; then33JAVAC_CMD=`which javac`34TESTJAVA=`dirname $JAVAC_CMD`/..35COMPILEJAVA="${TESTJAVA}"36fi3738# set platform-dependent variables39OS=`uname -s`40case "$OS" in41Windows_* )42FS="\\"43;;44* )45FS="/"46;;47esac4849KT="$TESTJAVA${FS}bin${FS}keytool -storepass changeit \50-keypass changeit -keystore certreplace.jks -keyalg rsa"51JAVAC=$COMPILEJAVA${FS}bin${FS}javac52JAVA=$TESTJAVA${FS}bin${FS}java5354rm -rf certreplace.jks 2> /dev/null5556# 1. Generate 3 aliases in a keystore: ca, int, user5758$KT -genkeypair -alias ca -dname CN=CA -keyalg rsa -sigalg md2withrsa -ext bc59$KT -genkeypair -alias int -dname CN=Int -keyalg rsa60$KT -genkeypair -alias user -dname CN=User -keyalg rsa6162# 2. Signing: ca -> int -> user6364$KT -certreq -alias int | $KT -gencert -rfc -alias ca -ext bc \65| $KT -import -alias int66$KT -certreq -alias user | $KT -gencert -rfc -alias int \67| $KT -import -alias user6869# 3. Create the certchain file7071$KT -export -alias user -rfc > certreplace.certs72$KT -export -rfc -alias int >> certreplace.certs73$KT -export -rfc -alias ca >> certreplace.certs7475# 4. Upgrade ca from MD2withRSA to SHA256withRSA, remove other aliases and76# make this keystore the cacerts file7778$KT -selfcert -alias ca79$KT -delete -alias int80$KT -delete -alias user8182# 5. Build and run test8384$JAVAC ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d . ${TESTSRC}${FS}CertReplace.java85$JAVA ${TESTVMOPTS} CertReplace certreplace.jks certreplace.certs868788