Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/sun/security/tools/keytool/trystore.sh
38854 views
#1# Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.2# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3#4# This code is free software; you can redistribute it and/or modify it5# under the terms of the GNU General Public License version 2 only, as6# published by the Free Software Foundation.7#8# This code is distributed in the hope that it will be useful, but WITHOUT9# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11# version 2 for more details (a copy is included in the LICENSE file that12# accompanied this code).13#14# You should have received a copy of the GNU General Public License version15# 2 along with this work; if not, write to the Free Software Foundation,16# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17#18# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19# or visit www.oracle.com if you need additional information or have any20# questions.21#2223# @test24# @bug 704720025# @summary keytool can try save to a byte array before overwrite the file2627if [ "${TESTJAVA}" = "" ] ; then28JAVAC_CMD=`which javac`29TESTJAVA=`dirname $JAVAC_CMD`/..30fi3132# set platform-dependent variables33OS=`uname -s`34case "$OS" in35Windows_* )36FS="\\"37;;38* )39FS="/"40;;41esac4243rm trystore.jks 2> /dev/null4445KEYTOOL="${TESTJAVA}${FS}bin${FS}keytool -storetype jks -keystore trystore.jks -keyalg rsa"46$KEYTOOL -genkeypair -alias a -dname CN=A -storepass changeit -keypass changeit47$KEYTOOL -genkeypair -alias b -dname CN=B -storepass changeit -keypass changeit4849# We use -protected for JKS keystore. This is illegal so the command should50# fail. Then we can check if the keystore is damaged.5152$KEYTOOL -genkeypair -protected -alias b -delete -debug5354if [ $? = 0 ]; then55echo "What? -protected works for JKS?"56exit 157fi5859$KEYTOOL -list -storepass changeit6061if [ $? != 0 ]; then62echo "Keystore file damaged"63exit 264fi656667