Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/sun/security/tools/jarsigner/certpolicy.sh
38854 views
#1# Copyright (c) 2014, 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 803670925# @summary Java 7 jarsigner displays warning about cert policy tree26#27# @run shell certpolicy.sh28#2930if [ "${TESTJAVA}" = "" ] ; then31JAVAC_CMD=`which javac`32TESTJAVA=`dirname $JAVAC_CMD`/..33fi3435KT="$TESTJAVA/bin/keytool $TESTTOOLVMOPTS \36-keypass changeit -storepass changeit -keystore ks -keyalg rsa"37JS="$TESTJAVA/bin/jarsigner $TESTTOOLVMOPTS -storepass changeit -keystore ks"38JAR="$TESTJAVA/bin/jar $TESTTOOLVMOPTS"3940rm ks 2> /dev/null41$KT -genkeypair -alias ca -dname CN=CA -ext bc42$KT -genkeypair -alias int -dname CN=Int43$KT -genkeypair -alias ee -dname CN=EE4445# CertificatePolicies [[PolicyId: [1.2.3]], [PolicyId: [1.2.4]]]46# PolicyConstraints: [Require: 0; Inhibit: unspecified]47$KT -certreq -alias int | \48$KT -gencert -rfc -alias ca \49-ext 2.5.29.32="30 0C 30 04 06 02 2A 03 30 04 06 02 2A 04" \50-ext "2.5.29.36=30 03 80 01 00" -ext bc | \51$KT -import -alias int5253# CertificatePolicies [[PolicyId: [1.2.3]]]54$KT -certreq -alias ee | \55$KT -gencert -rfc -alias int \56-ext 2.5.29.32="30 06 30 04 06 02 2A 03" | \57$KT -import -alias ee5859$KT -export -alias ee -rfc > cc60$KT -export -alias int -rfc >> cc61$KT -export -alias ca -rfc >> cc6263$KT -delete -alias int6465ERR=''66$JAR cvf a.jar cc6768# Make sure the certchain in the signed jar contains all 3 certs69$JS -strict -certchain cc a.jar ee -debug || ERR="sign"70$JS -strict -verify a.jar -debug || ERR="$ERR verify"7172if [ "$ERR" = "" ]; then73echo "Success"74exit 075else76echo "Failed: $ERR"77exit 178fi79808182