selfissued.sh revision 2306
1031N/A#
2306N/A# Copyright 2009-2010 Sun Microsystems, Inc. All Rights Reserved.
1031N/A# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1031N/A#
1031N/A# This code is free software; you can redistribute it and/or modify it
1031N/A# under the terms of the GNU General Public License version 2 only, as
1031N/A# published by the Free Software Foundation.
1031N/A#
1031N/A# This code is distributed in the hope that it will be useful, but WITHOUT
1031N/A# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1031N/A# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
1031N/A# version 2 for more details (a copy is included in the LICENSE file that
1031N/A# accompanied this code).
1031N/A#
1031N/A# You should have received a copy of the GNU General Public License version
1031N/A# 2 along with this work; if not, write to the Free Software Foundation,
1031N/A# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1031N/A#
1031N/A# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
1031N/A# CA 95054 USA or visit www.sun.com if you need additional information or
1031N/A# have any questions.
1031N/A#
1031N/A
1031N/A# @test
2306N/A# @bug 6825352 6937978
2306N/A# @summary support self-issued certificate in keytool and let -gencert generate the chain
1031N/A#
1031N/A# @run shell selfissued.sh
1031N/A#
1031N/A
1031N/Aif [ "${TESTJAVA}" = "" ] ; then
1031N/A JAVAC_CMD=`which javac`
1031N/A TESTJAVA=`dirname $JAVAC_CMD`/..
1031N/Afi
1031N/A
1031N/A# set platform-dependent variables
1031N/AOS=`uname -s`
1031N/Acase "$OS" in
1031N/A Windows_* )
1031N/A FS="\\"
1031N/A ;;
1031N/A * )
1031N/A FS="/"
1031N/A ;;
1031N/Aesac
1031N/A
1031N/AKS=selfsigned.jks
1031N/AKT="$TESTJAVA${FS}bin${FS}keytool -storepass changeit -keypass changeit -keystore $KS"
1031N/A
1031N/Arm $KS
1031N/A
1031N/A$KT -alias ca -dname CN=CA -genkeypair
2306N/A$KT -alias ca1 -dname CN=CA -genkeypair
2306N/A$KT -alias ca2 -dname CN=CA -genkeypair
1031N/A$KT -alias e1 -dname CN=E1 -genkeypair
1031N/A
2306N/A# ca signs ca1, ca1 signs ca2, all self-issued
2306N/A$KT -alias ca1 -certreq | $KT -alias ca -gencert -ext san=dns:ca1 \
2306N/A | $KT -alias ca1 -importcert
2306N/A$KT -alias ca2 -certreq | $KT -alias ca1 -gencert -ext san=dns:ca2 \
2306N/A | $KT -alias ca2 -importcert
1031N/A
2306N/A# Import e1 signed by ca2, should add ca2 and ca1, at least 3 certs in the chain
2306N/A$KT -alias e1 -certreq | $KT -alias ca2 -gencert > e1.cert
2306N/A$KT -alias ca1 -delete
2306N/A$KT -alias ca2 -delete
2306N/Acat e1.cert | $KT -alias e1 -importcert
2306N/A$KT -alias e1 -list -v | grep '\[3\]' || { echo Bad E1; exit 1; }
1031N/A
1031N/Aecho Good
1031N/A