Path: blob/master/test/jdk/sun/security/provider/certpath/DisabledAlgorithms/generate.sh
41154 views
#1# Copyright (c) 2009, 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. Oracle designates this7# particular file as subject to the "Classpath" exception as provided8# by Oracle in the LICENSE file that accompanied this code.9#10# This code is distributed in the hope that it will be useful, but WITHOUT11# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13# version 2 for more details (a copy is included in the LICENSE file that14# accompanied this code).15#16# You should have received a copy of the GNU General Public License version17# 2 along with this work; if not, write to the Free Software Foundation,18# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19#20# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21# or visit www.oracle.com if you need additional information or have any22# questions.23#2425#!/bin/ksh26#27# needs ksh to run the script.28set -e2930OPENSSL=openssl3132# generate a self-signed root certificate33if [ ! -f root/finished ]; then34if [ ! -d root ]; then35mkdir root36fi3738# SHA1withRSA 102439${OPENSSL} req -x509 -newkey rsa:1024 -keyout root/root_key_1024.pem \40-out root/root_cert_sha1_1024.pem -subj "/C=US/O=Example" \41-config openssl.cnf -reqexts cert_issuer -days 7650 -sha1 \42-passin pass:passphrase -passout pass:passphrase4344# SHA1withRSA 51245${OPENSSL} req -x509 -newkey rsa:512 -keyout root/root_key_512.pem \46-out root/root_cert_sha1_512.pem -subj "/C=US/O=Example" \47-config openssl.cnf -reqexts cert_issuer -days 7650 -sha1 \48-passin pass:passphrase -passout pass:passphrase4950# MD2withRSA 204851${OPENSSL} req -x509 -newkey rsa:2048 -keyout root/root_key_2048.pem \52-out root/root_cert_md2_2048.pem -subj "/C=US/O=Example" \53-config openssl.cnf -reqexts cert_issuer -days 7650 -md2 \54-passin pass:passphrase -passout pass:passphrase5556openssl req -newkey rsa:1024 -keyout root/root_crlissuer_key.pem \57-out root/root_crlissuer_req.pem -subj "/C=US/O=Example" -days 7650 \58-passin pass:passphrase -passout pass:passphrase5960openssl x509 -req -in root/root_crlissuer_req.pem -extfile openssl.cnf \61-extensions crl_issuer -CA root/root_cert_sha1_1024.pem \62-CAkey root/root_key_1024.pem -out root/root_crlissuer_cert.pem \63-CAcreateserial -CAserial root/root_cert.srl -days 7200 \64-passin pass:passphrase6566touch root/finished67fi686970# generate subca cert issuer71if [ ! -f subca/finished ]; then72if [ ! -d subca ]; then73mkdir subca74fi7576# RSA 102477${OPENSSL} req -newkey rsa:1024 -keyout subca/subca_key_1024.pem \78-out subca/subca_req_1024.pem -subj "/C=US/O=Example/OU=Class-1" \79-days 7650 -passin pass:passphrase -passout pass:passphrase8081# RSA 51282${OPENSSL} req -newkey rsa:512 -keyout subca/subca_key_512.pem \83-out subca/subca_req_512.pem -subj "/C=US/O=Example/OU=Class-1" \84-days 7650 -passin pass:passphrase -passout pass:passphrase8586# SHA1withRSA 1024 signed with RSA 102487${OPENSSL} x509 -req -in subca/subca_req_1024.pem -extfile openssl.cnf \88-extensions cert_issuer -CA root/root_cert_sha1_1024.pem \89-CAkey root/root_key_1024.pem -out subca/subca_cert_sha1_1024_1024.pem \90-CAcreateserial -sha1 \91-CAserial root/root_cert.srl -days 7200 -passin pass:passphrase9293# SHA1withRSA 1024 signed with RSA 51294${OPENSSL} x509 -req -in subca/subca_req_1024.pem -extfile openssl.cnf \95-extensions cert_issuer -CA root/root_cert_sha1_512.pem \96-CAkey root/root_key_512.pem -out subca/subca_cert_sha1_1024_512.pem \97-CAcreateserial -sha1 \98-CAserial root/root_cert.srl -days 7200 -passin pass:passphrase99100# SHA1withRSA 512 signed with RSA 1024101${OPENSSL} x509 -req -in subca/subca_req_512.pem -extfile openssl.cnf \102-extensions cert_issuer -CA root/root_cert_sha1_1024.pem \103-CAkey root/root_key_1024.pem -out subca/subca_cert_sha1_512_1024.pem \104-CAcreateserial -sha1 \105-CAserial root/root_cert.srl -days 7200 -passin pass:passphrase106107# SHA1withRSA 512 signed with RSA 512108${OPENSSL} x509 -req -in subca/subca_req_512.pem -extfile openssl.cnf \109-extensions cert_issuer -CA root/root_cert_sha1_512.pem \110-CAkey root/root_key_512.pem -out subca/subca_cert_sha1_512_512.pem \111-CAcreateserial -sha1 \112-CAserial root/root_cert.srl -days 7200 -passin pass:passphrase113114# MD2withRSA 1024 signed with RSA 1024115${OPENSSL} x509 -req -in subca/subca_req_1024.pem -extfile openssl.cnf \116-extensions cert_issuer -CA root/root_cert_sha1_1024.pem \117-CAkey root/root_key_1024.pem -out subca/subca_cert_md2_1024_1024.pem \118-CAcreateserial -md2 \119-CAserial root/root_cert.srl -days 7200 -passin pass:passphrase120121# MD2withRSA 1024 signed with RSA 512122${OPENSSL} x509 -req -in subca/subca_req_1024.pem -extfile openssl.cnf \123-extensions cert_issuer -CA root/root_cert_sha1_512.pem \124-CAkey root/root_key_512.pem -out subca/subca_cert_md2_1024_512.pem \125-CAcreateserial -md2 \126-CAserial root/root_cert.srl -days 7200 -passin pass:passphrase127128openssl req -newkey rsa:1024 -keyout subca/subca_crlissuer_key.pem \129-out subca/subca_crlissuer_req.pem -subj "/C=US/O=Example/OU=Class-1" \130-days 7650 -passin pass:passphrase -passout pass:passphrase131132openssl x509 -req -in subca/subca_crlissuer_req.pem -extfile openssl.cnf \133-extensions crl_issuer -CA root/root_cert_sha1_1024.pem \134-CAkey root/root_key_1024.pem -out subca/subca_crlissuer_cert.pem \135-CAcreateserial -CAserial root/root_cert.srl -days 7200 \136-passin pass:passphrase137138touch subca/finished139fi140141142# generate certifiacte for Alice143if [ ! -f subca/alice/finished ]; then144if [ ! -d subca/alice ]; then145mkdir -p subca/alice146fi147148# RSA 1024149${OPENSSL} req -newkey rsa:1024 -keyout subca/alice/alice_key_1024.pem \150-out subca/alice/alice_req_1024.pem \151-subj "/C=US/O=Example/OU=Class-1/CN=Alice" -days 7650 \152-passin pass:passphrase -passout pass:passphrase153154# RSA 512155${OPENSSL} req -newkey rsa:512 -keyout subca/alice/alice_key_512.pem \156-out subca/alice/alice_req_512.pem \157-subj "/C=US/O=Example/OU=Class-1/CN=Alice" -days 7650 \158-passin pass:passphrase -passout pass:passphrase159160# SHA1withRSA 1024 signed with RSA 1024161${OPENSSL} x509 -req -in subca/alice/alice_req_1024.pem \162-extfile openssl.cnf -extensions ee_of_subca \163-CA subca/subca_cert_sha1_1024_1024.pem \164-CAkey subca/subca_key_1024.pem \165-out subca/alice/alice_cert_sha1_1024_1024.pem -CAcreateserial -sha1 \166-CAserial subca/subca_cert.srl -days 7200 -passin pass:passphrase167168# SHA1withRSA 1024 signed with RSA 512169${OPENSSL} x509 -req -in subca/alice/alice_req_1024.pem \170-extfile openssl.cnf -extensions ee_of_subca \171-CA subca/subca_cert_sha1_512_1024.pem \172-CAkey subca/subca_key_512.pem \173-out subca/alice/alice_cert_sha1_1024_512.pem -CAcreateserial -sha1 \174-CAserial subca/subca_cert.srl -days 7200 -passin pass:passphrase175176# SHA1withRSA 512 signed with RSA 1024177${OPENSSL} x509 -req -in subca/alice/alice_req_512.pem \178-extfile openssl.cnf -extensions ee_of_subca \179-CA subca/subca_cert_sha1_1024_1024.pem \180-CAkey subca/subca_key_1024.pem \181-out subca/alice/alice_cert_sha1_512_1024.pem -CAcreateserial -sha1 \182-CAserial subca/subca_cert.srl -days 7200 -passin pass:passphrase183184# SHA1withRSA 512 signed with RSA 512185${OPENSSL} x509 -req -in subca/alice/alice_req_512.pem \186-extfile openssl.cnf -extensions ee_of_subca \187-CA subca/subca_cert_sha1_512_1024.pem \188-CAkey subca/subca_key_512.pem \189-out subca/alice/alice_cert_sha1_512_512.pem -CAcreateserial -sha1 \190-CAserial subca/subca_cert.srl -days 7200 -passin pass:passphrase191192# MD2withRSA 1024 signed with RSA 1024193${OPENSSL} x509 -req -in subca/alice/alice_req_1024.pem \194-extfile openssl.cnf -extensions ee_of_subca \195-CA subca/subca_cert_sha1_1024_1024.pem \196-CAkey subca/subca_key_1024.pem \197-out subca/alice/alice_cert_md2_1024_1024.pem -CAcreateserial -md2 \198-CAserial subca/subca_cert.srl -days 7200 -passin pass:passphrase199200# MD2withRSA 1024 signed with RSA 512201${OPENSSL} x509 -req -in subca/alice/alice_req_1024.pem \202-extfile openssl.cnf -extensions ee_of_subca \203-CA subca/subca_cert_sha1_512_1024.pem \204-CAkey subca/subca_key_512.pem \205-out subca/alice/alice_cert_md2_1024_512.pem -CAcreateserial -md2 \206-CAserial subca/subca_cert.srl -days 7200 -passin pass:passphrase207208touch subca/alice/finished209fi210211if [ ! -f root/revoked ]; then212if [ ! -d root ]; then213mkdir root214fi215216if [ ! -f root/index.txt ]; then217touch root/index.txt218echo 00 > root/crlnumber219fi220221openssl ca -gencrl -config openssl.cnf -name ca_top -crldays 7000 -md sha1 \222-crl_reason superseded -keyfile root/root_crlissuer_key.pem \223-cert root/root_crlissuer_cert.pem -out root/top_crl.pem \224-passin pass:passphrase225226touch root/revoked227fi228229if [ ! -f subca/revoked ]; then230if [ ! -d subca ]; then231mkdir subca232fi233234if [ ! -f subca/index.txt ]; then235touch subca/index.txt236echo 00 > subca/crlnumber237fi238239# revoke alice's SHA1withRSA 1024 signed with RSA 1024240openssl ca -revoke subca/alice/alice_cert_sha1_1024_1024.pem \241-config openssl.cnf \242-name ca_subca -crl_reason superseded \243-keyfile subca/subca_crlissuer_key.pem \244-cert subca/subca_crlissuer_cert.pem -passin pass:passphrase245246openssl ca -gencrl -config openssl.cnf \247-name ca_subca -crldays 7000 -md md2 \248-crl_reason superseded -keyfile subca/subca_crlissuer_key.pem \249-cert subca/subca_crlissuer_cert.pem \250-out subca/subca_crl.pem \251-passin pass:passphrase252253touch subca/revoked254fi255256257