test/jdk/sun/security/tools/keytool/emptysubject.sh
branchniosocketimpl-branch
changeset 57322 4744fdcf458c
parent 57321 eef9324f94cc
parent 54527 96d290a7e94f
child 57336 766140c67efa
equal deleted inserted replaced
57321:eef9324f94cc 57322:4744fdcf458c
     1 #
       
     2 # Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
       
     3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       
     4 #
       
     5 # This code is free software; you can redistribute it and/or modify it
       
     6 # under the terms of the GNU General Public License version 2 only, as
       
     7 # published by the Free Software Foundation.
       
     8 #
       
     9 # This code is distributed in the hope that it will be useful, but WITHOUT
       
    10 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       
    11 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
       
    12 # version 2 for more details (a copy is included in the LICENSE file that
       
    13 # accompanied this code).
       
    14 #
       
    15 # You should have received a copy of the GNU General Public License version
       
    16 # 2 along with this work; if not, write to the Free Software Foundation,
       
    17 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
       
    18 #
       
    19 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
       
    20 # or visit www.oracle.com if you need additional information or have any
       
    21 # questions.
       
    22 #
       
    23 
       
    24 # @test
       
    25 # @bug 6847026
       
    26 # @summary keytool should be able to generate certreq and cert without subject name
       
    27 #
       
    28 # @run shell emptysubject.sh
       
    29 #
       
    30 
       
    31 if [ "${TESTJAVA}" = "" ] ; then
       
    32   JAVAC_CMD=`which javac`
       
    33   TESTJAVA=`dirname $JAVAC_CMD`/..
       
    34 fi
       
    35 
       
    36 # set platform-dependent variables
       
    37 OS=`uname -s`
       
    38 case "$OS" in
       
    39   Windows_* )
       
    40     FS="\\"
       
    41     ;;
       
    42   * )
       
    43     FS="/"
       
    44     ;;
       
    45 esac
       
    46 
       
    47 KS=emptysubject.jks
       
    48 KT="$TESTJAVA${FS}bin${FS}keytool ${TESTTOOLVMOPTS} -storepass changeit -keypass changeit -keystore $KS -keyalg rsa"
       
    49 
       
    50 rm $KS
       
    51 
       
    52 $KT -alias ca -dname CN=CA -genkeypair
       
    53 $KT -alias me -dname CN=Me -genkeypair
       
    54 
       
    55 # When -dname is recognized, SAN must be specfied, otherwise, -printcert fails.
       
    56 $KT -alias me -certreq -dname "" | \
       
    57         $KT -alias ca -gencert | $KT -printcert && exit 1
       
    58 $KT -alias me -certreq | \
       
    59         $KT -alias ca -gencert -dname "" | $KT -printcert && exit 2
       
    60 $KT -alias me -certreq -dname "" | \
       
    61         $KT -alias ca -gencert -ext san:c=email:me@me.com | \
       
    62         $KT -printcert || exit 3
       
    63 $KT -alias me -certreq | \
       
    64         $KT -alias ca -gencert -dname "" -ext san:c=email:me@me.com | \
       
    65         $KT -printcert || exit 4
       
    66 
       
    67 exit 0
       
    68