Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/sun/security/validator/samedn.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 695886925# @summary regression: PKIXValidator fails when multiple trust anchors26# have same dn27#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 samedn.jks -keyalg rsa"51JAVAC=$COMPILEJAVA${FS}bin${FS}javac52JAVA=$TESTJAVA${FS}bin${FS}java5354rm -rf samedn.jks 2> /dev/null5556# 1. Generate 3 aliases in a keystore: ca1, ca2, user. The CAs' startdate57# is set to one year ago so that they are expired now5859$KT -genkeypair -alias ca1 -dname CN=CA -keyalg rsa -sigalg md5withrsa -ext bc -startdate -1y60$KT -genkeypair -alias ca2 -dname CN=CA -keyalg rsa -sigalg sha1withrsa -ext bc -startdate -1y61$KT -genkeypair -alias user -dname CN=User -keyalg rsa6263# 2. Signing: ca -> user6465$KT -certreq -alias user | $KT -gencert -rfc -alias ca1 > samedn1.certs66$KT -certreq -alias user | $KT -gencert -rfc -alias ca2 > samedn2.certs6768# 3. Append the ca file6970$KT -export -rfc -alias ca1 >> samedn1.certs71$KT -export -rfc -alias ca2 >> samedn2.certs7273# 4. Remove user for cacerts7475$KT -delete -alias user7677# 5. Build and run test. Make sure the CA certs are ignored for validity check.78# Check both, one of them might be dropped out of map in old codes.7980$JAVAC ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d . ${TESTSRC}${FS}CertReplace.java81$JAVA ${TESTVMOPTS} CertReplace samedn.jks samedn1.certs || exit 182$JAVA ${TESTVMOPTS} CertReplace samedn.jks samedn2.certs || exit 2838485