1423N/A#
2362N/A# Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
1423N/A# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1423N/A#
1423N/A# This code is free software; you can redistribute it and/or modify it
1423N/A# under the terms of the GNU General Public License version 2 only, as
1423N/A# published by the Free Software Foundation.
1423N/A#
1423N/A# This code is distributed in the hope that it will be useful, but WITHOUT
1423N/A# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1423N/A# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
1423N/A# version 2 for more details (a copy is included in the LICENSE file that
1423N/A# accompanied this code).
1423N/A#
1423N/A# You should have received a copy of the GNU General Public License version
1423N/A# 2 along with this work; if not, write to the Free Software Foundation,
1423N/A# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1423N/A#
2362N/A# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A# or visit www.oracle.com if you need additional information or have any
2362N/A# questions.
1423N/A#
1423N/A
1423N/A# @test
1423N/A# @bug 6847026
1423N/A# @summary keytool should be able to generate certreq and cert without subject name
1423N/A#
1423N/A# @run shell emptysubject.sh
1423N/A#
1423N/A
1423N/Aif [ "${TESTJAVA}" = "" ] ; then
1423N/A JAVAC_CMD=`which javac`
1423N/A TESTJAVA=`dirname $JAVAC_CMD`/..
1423N/Afi
1423N/A
1423N/A# set platform-dependent variables
1423N/AOS=`uname -s`
1423N/Acase "$OS" in
1423N/A Windows_* )
1423N/A FS="\\"
1423N/A ;;
1423N/A * )
1423N/A FS="/"
1423N/A ;;
1423N/Aesac
1423N/A
1423N/AKS=emptysubject.jks
1423N/AKT="$TESTJAVA${FS}bin${FS}keytool -storepass changeit -keypass changeit -keystore $KS"
1423N/A
1423N/Arm $KS
1423N/A
1423N/A$KT -alias ca -dname CN=CA -genkeypair
1423N/A$KT -alias me -dname CN=Me -genkeypair
1423N/A
1423N/A# When -dname is recognized, SAN must be specfied, otherwise, -printcert fails.
1423N/A$KT -alias me -certreq -dname "" | \
1423N/A $KT -alias ca -gencert | $KT -printcert && exit 1
1423N/A$KT -alias me -certreq | \
1423N/A $KT -alias ca -gencert -dname "" | $KT -printcert && exit 2
1423N/A$KT -alias me -certreq -dname "" | \
1423N/A $KT -alias ca -gencert -ext san:c=email:me@me.com | \
1423N/A $KT -printcert || exit 3
1423N/A$KT -alias me -certreq | \
1423N/A $KT -alias ca -gencert -dname "" -ext san:c=email:me@me.com | \
1423N/A $KT -printcert || exit 4
1423N/A
1423N/Aexit 0
1423N/A