Path: blob/master/test/jdk/sun/security/validator/samedn.sh
41149 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# @modules java.base/sun.security.validator28#2930if [ "${TESTSRC}" = "" ] ; then31TESTSRC="."32fi33if [ "${TESTJAVA}" = "" ] ; then34JAVAC_CMD=`which javac`35TESTJAVA=`dirname $JAVAC_CMD`/..36COMPILEJAVA="${TESTJAVA}"37fi3839# set platform-dependent variables40OS=`uname -s`41case "$OS" in42Windows_* )43FS="\\"44;;45* )46FS="/"47;;48esac4950KT="$TESTJAVA${FS}bin${FS}keytool ${TESTTOOLVMOPTS} -storepass changeit \51-keypass changeit -keystore samedn.jks -keyalg rsa"52JAVAC=$COMPILEJAVA${FS}bin${FS}javac53JAVA=$TESTJAVA${FS}bin${FS}java5455rm -rf samedn.jks 2> /dev/null5657# 1. Generate 3 aliases in a keystore: ca1, ca2, user. The CAs' startdate58# is set to one year ago so that they are expired now5960$KT -genkeypair -alias ca1 -dname CN=CA -keyalg rsa -sigalg md5withrsa -ext bc -startdate -1y61$KT -genkeypair -alias ca2 -dname CN=CA -keyalg rsa -sigalg sha1withrsa -ext bc -startdate -1y62$KT -genkeypair -alias user -dname CN=User -keyalg rsa6364# 2. Signing: ca -> user6566$KT -certreq -alias user | $KT -gencert -rfc -alias ca1 > samedn1.certs67$KT -certreq -alias user | $KT -gencert -rfc -alias ca2 > samedn2.certs6869# 3. Append the ca file7071$KT -export -rfc -alias ca1 >> samedn1.certs72$KT -export -rfc -alias ca2 >> samedn2.certs7374# 4. Remove user for cacerts7576$KT -delete -alias user7778# 5. Build and run test. Make sure the CA certs are ignored for validity check.79# Check both, one of them might be dropped out of map in old codes.8081EXTRAOPTS="--add-exports java.base/sun.security.validator=ALL-UNNAMED"82$JAVAC ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} ${EXTRAOPTS} -d . ${TESTSRC}${FS}CertReplace.java83$JAVA ${TESTVMOPTS} ${EXTRAOPTS} CertReplace samedn.jks samedn1.certs || exit 184$JAVA ${TESTVMOPTS} ${EXTRAOPTS} CertReplace samedn.jks samedn2.certs || exit 2858687