2469N/A#
2469N/A# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
2469N/A# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2469N/A#
2469N/A# This code is free software; you can redistribute it and/or modify it
2469N/A# under the terms of the GNU General Public License version 2 only, as
2469N/A# published by the Free Software Foundation.
2469N/A#
2469N/A# This code is distributed in the hope that it will be useful, but WITHOUT
2469N/A# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
2469N/A# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
2469N/A# version 2 for more details (a copy is included in the LICENSE file that
2469N/A# accompanied this code).
2469N/A#
2469N/A# You should have received a copy of the GNU General Public License version
2469N/A# 2 along with this work; if not, write to the Free Software Foundation,
2469N/A# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
2469N/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.
2469N/A#
2469N/A
2469N/A# @test
2469N/A# @bug 6958869
2469N/A# @summary regression: PKIXValidator fails when multiple trust anchors
2469N/A# have same dn
2469N/A#
2469N/A
2469N/Aif [ "${TESTSRC}" = "" ] ; then
2469N/A TESTSRC="."
2469N/Afi
2469N/Aif [ "${TESTJAVA}" = "" ] ; then
2469N/A JAVAC_CMD=`which javac`
2469N/A TESTJAVA=`dirname $JAVAC_CMD`/..
2469N/Afi
2469N/A
2469N/A# set platform-dependent variables
2469N/AOS=`uname -s`
2469N/Acase "$OS" in
2469N/A Windows_* )
2469N/A FS="\\"
2469N/A ;;
2469N/A * )
2469N/A FS="/"
2469N/A ;;
2469N/Aesac
2469N/A
2469N/AKT="$TESTJAVA${FS}bin${FS}keytool -storepass changeit \
2469N/A -keypass changeit -keystore samedn.jks"
2469N/AJAVAC=$TESTJAVA${FS}bin${FS}javac
2469N/AJAVA=$TESTJAVA${FS}bin${FS}java
2469N/A
2469N/Arm -rf samedn.jks 2> /dev/null
2469N/A
2469N/A# 1. Generate 3 aliases in a keystore: ca1, ca2, user. The CAs' startdate
2469N/A# is set to one year ago so that they are expired now
2469N/A
2469N/A$KT -genkeypair -alias ca1 -dname CN=CA -keyalg rsa -sigalg md5withrsa -ext bc -startdate -1y
2469N/A$KT -genkeypair -alias ca2 -dname CN=CA -keyalg rsa -sigalg sha1withrsa -ext bc -startdate -1y
2469N/A$KT -genkeypair -alias user -dname CN=User -keyalg rsa
2469N/A
2469N/A# 2. Signing: ca -> user
2469N/A
2469N/A$KT -certreq -alias user | $KT -gencert -rfc -alias ca1 > samedn1.certs
2469N/A$KT -certreq -alias user | $KT -gencert -rfc -alias ca2 > samedn2.certs
2469N/A
2469N/A# 3. Append the ca file
2469N/A
2469N/A$KT -export -rfc -alias ca1 >> samedn1.certs
2469N/A$KT -export -rfc -alias ca2 >> samedn2.certs
2469N/A
2469N/A# 4. Remove user for cacerts
2469N/A
2469N/A$KT -delete -alias user
2469N/A
2469N/A# 5. Build and run test. Make sure the CA certs are ignored for validity check.
2469N/A# Check both, one of them might be dropped out of map in old codes.
2469N/A
2469N/A$JAVAC -d . ${TESTSRC}${FS}CertReplace.java
2469N/A$JAVA CertReplace samedn.jks samedn1.certs || exit 1
2469N/A$JAVA CertReplace samedn.jks samedn2.certs || exit 2