jdk/test/sun/security/validator/certreplace.sh
author weijun
Fri, 25 Apr 2014 10:57:09 +0800
changeset 24116 9f9b4ba34aad
parent 23010 6dadb192ad81
child 36511 9d0388c6b336
permissions -rw-r--r--
8040321: keytool and jarsigner tests doesn't pass though VM tools to tools Reviewed-by: alanb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5613
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
     1
#
23010
6dadb192ad81 8029235: Update copyright year to match last edit in jdk8 jdk repository for 2013
lana
parents: 21342
diff changeset
     2
# Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
5613
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
     3
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
     4
#
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
     5
# This code is free software; you can redistribute it and/or modify it
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
     6
# under the terms of the GNU General Public License version 2 only, as
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
     7
# published by the Free Software Foundation.
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
     8
#
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
     9
# This code is distributed in the hope that it will be useful, but WITHOUT
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    10
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    11
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    12
# version 2 for more details (a copy is included in the LICENSE file that
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    13
# accompanied this code).
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    14
#
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    15
# You should have received a copy of the GNU General Public License version
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    16
# 2 along with this work; if not, write to the Free Software Foundation,
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    17
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    18
#
5782
50575882b36f 6958869: regression: PKIXValidator fails when multiple trust anchors have same dn
weijun
parents: 5613
diff changeset
    19
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
50575882b36f 6958869: regression: PKIXValidator fails when multiple trust anchors have same dn
weijun
parents: 5613
diff changeset
    20
# or visit www.oracle.com if you need additional information or have any
50575882b36f 6958869: regression: PKIXValidator fails when multiple trust anchors have same dn
weijun
parents: 5613
diff changeset
    21
# questions.
5613
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    22
#
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    23
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    24
# @test
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    25
# @bug 6948803
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    26
# @summary CertPath validation regression caused by SHA1 replacement root
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    27
#  and MD2 disable feature
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    28
#
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    29
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    30
if [ "${TESTSRC}" = "" ] ; then
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    31
  TESTSRC="."
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    32
fi
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    33
if [ "${TESTJAVA}" = "" ] ; then
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    34
  JAVAC_CMD=`which javac`
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    35
  TESTJAVA=`dirname $JAVAC_CMD`/..
15254
3997a6f357cb 8005978: shell tests need to use the $COMPILEJDK for javac, jar and other tools
alanb
parents: 14786
diff changeset
    36
  COMPILEJAVA="${TESTJAVA}"
5613
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    37
fi
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    38
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    39
# set platform-dependent variables
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    40
OS=`uname -s`
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    41
case "$OS" in
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    42
  Windows_* )
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    43
    FS="\\"
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    44
    ;;
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    45
  * )
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    46
    FS="/"
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    47
    ;;
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    48
esac
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    49
24116
9f9b4ba34aad 8040321: keytool and jarsigner tests doesn't pass though VM tools to tools
weijun
parents: 23010
diff changeset
    50
KT="$TESTJAVA${FS}bin${FS}keytool ${TESTTOOLVMOPTS} -storepass changeit \
21342
7bbb056a1c23 8027026: Change keytool -genkeypair to use -keyalg RSA
weijun
parents: 15254
diff changeset
    51
    -keypass changeit -keystore certreplace.jks -keyalg rsa"
15254
3997a6f357cb 8005978: shell tests need to use the $COMPILEJDK for javac, jar and other tools
alanb
parents: 14786
diff changeset
    52
JAVAC=$COMPILEJAVA${FS}bin${FS}javac
5613
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    53
JAVA=$TESTJAVA${FS}bin${FS}java
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    54
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    55
rm -rf certreplace.jks 2> /dev/null
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    56
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    57
# 1. Generate 3 aliases in a keystore: ca, int, user
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    58
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    59
$KT -genkeypair -alias ca -dname CN=CA -keyalg rsa -sigalg md2withrsa -ext bc
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    60
$KT -genkeypair -alias int -dname CN=Int -keyalg rsa
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    61
$KT -genkeypair -alias user -dname CN=User -keyalg rsa
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    62
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    63
# 2. Signing: ca -> int -> user
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    64
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    65
$KT -certreq -alias int | $KT -gencert -rfc -alias ca -ext bc \
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    66
    | $KT -import -alias int
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    67
$KT -certreq -alias user | $KT -gencert -rfc -alias int \
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    68
    | $KT -import -alias user
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    69
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    70
# 3. Create the certchain file
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    71
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    72
$KT -export -alias user -rfc > certreplace.certs
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    73
$KT -export -rfc -alias int >> certreplace.certs
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    74
$KT -export -rfc -alias ca >> certreplace.certs
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    75
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    76
# 4. Upgrade ca from MD2withRSA to SHA256withRSA, remove other aliases and
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    77
# make this keystore the cacerts file
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    78
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    79
$KT -selfcert -alias ca
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    80
$KT -delete -alias int
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    81
$KT -delete -alias user
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    82
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    83
# 5. Build and run test
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    84
15254
3997a6f357cb 8005978: shell tests need to use the $COMPILEJDK for javac, jar and other tools
alanb
parents: 14786
diff changeset
    85
$JAVAC ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d . ${TESTSRC}${FS}CertReplace.java
14786
a9f61e0cbe61 8003890: corelibs test scripts should pass TESTVMOPTS
chegar
parents: 5782
diff changeset
    86
$JAVA ${TESTVMOPTS} CertReplace certreplace.jks certreplace.certs