jdk/test/sun/security/validator/certreplace.sh
author chegar
Wed, 29 Aug 2012 14:05:37 +0100
changeset 14215 3ee2f6e24dbb
parent 5782 50575882b36f
child 14786 a9f61e0cbe61
permissions -rw-r--r--
7189567: java net obselete protocol Reviewed-by: alanb, ahgross
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
#
5782
50575882b36f 6958869: regression: PKIXValidator fails when multiple trust anchors have same dn
weijun
parents: 5613
diff changeset
     2
# Copyright (c) 2010, 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`/..
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    36
fi
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    37
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    38
# set platform-dependent variables
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    39
OS=`uname -s`
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    40
case "$OS" in
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    41
  Windows_* )
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    42
    FS="\\"
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    43
    ;;
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
    FS="/"
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    46
    ;;
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    47
esac
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    48
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    49
KT="$TESTJAVA${FS}bin${FS}keytool -storepass changeit \
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    50
    -keypass changeit -keystore certreplace.jks"
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    51
JAVAC=$TESTJAVA${FS}bin${FS}javac
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    52
JAVA=$TESTJAVA${FS}bin${FS}java
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    53
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    54
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
    55
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    56
# 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
    57
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    58
$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
    59
$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
    60
$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
    61
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    62
# 2. Signing: ca -> int -> user
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    63
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    64
$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
    65
    | $KT -import -alias int
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    66
$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
    67
    | $KT -import -alias user
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    68
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    69
# 3. Create the certchain file
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    70
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    71
$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
    72
$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
    73
$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
    74
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    75
# 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
    76
# make this keystore the cacerts file
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    77
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    78
$KT -selfcert -alias ca
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    79
$KT -delete -alias int
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    80
$KT -delete -alias user
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    81
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    82
# 5. Build and run test
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    83
1146efa21514 6948803: CertPath validation regression caused by SHA1 replacement root and MD2 disable feature
weijun
parents:
diff changeset
    84
$JAVAC -d . ${TESTSRC}${FS}CertReplace.java
5782
50575882b36f 6958869: regression: PKIXValidator fails when multiple trust anchors have same dn
weijun
parents: 5613
diff changeset
    85
$JAVA CertReplace certreplace.jks certreplace.certs