istio.io/istio@v0.0.0-20240520182934-d79c90f27776/security/pkg/pki/testdata/multilevelpki/certs.sh (about) 1 #!/bin/sh 2 3 # Copyright Istio Authors 4 # 5 # Licensed under the Apache License, Version 2.0 (the "License"); 6 # you may not use this file except in compliance with the License. 7 # You may obtain a copy of the License at 8 # 9 # http://www.apache.org/licenses/LICENSE-2.0 10 # 11 # Unless required by applicable law or agreed to in writing, software 12 # distributed under the License is distributed on an "AS IS" BASIS, 13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 # See the License for the specific language governing permissions and 15 # limitations under the License. 16 17 # This script generates all keys and certs in the 3level directory. 18 # There are 3 entities: root CA, intermeidate CA and intermediate CA2. The certificates of the 3 CAs form a certification chain. 19 20 # Root CA 21 #openssl genrsa -out root-key.pem 4096 22 openssl req -new -key root-key.pem -out root-cert.csr -sha256 <<EOF 23 US 24 California 25 Sunnyvale 26 Istio 27 Test 28 Root CA 29 test@istio.io 30 31 32 EOF 33 openssl x509 -req -days 3650 -in root-cert.csr -sha256 -signkey root-key.pem -out root-cert.pem 34 35 # Intermediate CA 36 #openssl genrsa -out int-key.pem 4096 37 openssl req -new -key int-key.pem -out int-cert.csr -config int-cert.cfg -batch -sha256 38 39 openssl x509 -req -days 3650 -in int-cert.csr -sha256 -CA root-cert.pem -CAkey root-key.pem -CAcreateserial -out int-cert.pem -extensions v3_req -extfile int-cert.cfg 40 41 # Intermediate CA2 42 #openssl genrsa -out int2-key.pem 4096 43 openssl req -new -key int2-key.pem -out int2-cert.csr -config int2-cert.cfg -batch -sha256 44 45 openssl x509 -req -days 3650 -in int2-cert.csr -sha256 -CA int-cert.pem -CAkey int-key.pem -CAcreateserial -out int2-cert.pem -extensions v3_req -extfile int2-cert.cfg 46 47 48 49 cat root-cert.pem > int-cert-chain.pem 50 cat int-cert.pem >> int-cert-chain.pem 51 cp int-cert-chain.pem int2-cert-chain.pem 52 cat int2-cert.pem >> int2-cert-chain.pem 53 54 rm ./*csr 55 rm ./*srl