Files
upstream-grpc-go/testdata/spiffe_end2end/intermediate_gen.sh
upstream-mirror e241b33f26
Some checks failed
codecov / upload (push) Failing after 13m59s
CodeQL / Analyze (push) Failing after 1s
Testing / vet-proto (push) Failing after 1s
Testing / tests (arm, latest) (push) Waiting to run
Testing / extras (latest) (push) Failing after 1s
Testing / static checks (latest-1) (push) Failing after 1s
Testing / tests (-race, latest) (push) Failing after 1s
Testing / tests (i386, latest) (push) Failing after 1s
Testing / tests (latest) (push) Failing after 1s
Testing / tests (latest-1) (push) Failing after 1s
Lock Threads / lock (push) Failing after 1s
govulncheck / govulncheck (.) (push) Failing after 1s
govulncheck / govulncheck (./cmd/protoc-gen-go-grpc) (push) Failing after 1s
govulncheck / govulncheck (./gcp/observability) (push) Failing after 1s
govulncheck / govulncheck (./security/advancedtls) (push) Failing after 1s
govulncheck / govulncheck (./stats/opencensus) (push) Failing after 1s
Stale bot / stale (push) Failing after 1s
snapshot of https://github.com/grpc/grpc-go.git (master, 2026-09-15; blobs > 131072B omitted)
2026-09-15 20:40:15 +05:00

56 lines
2.2 KiB
Bash
Executable File

#!/bin/bash
# Copyright 2025 gRPC authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -e
# Meant to be run from testdata/spiffe_end2end/
# Sets up an intermediate ca, generates certificates, then copies then up and deletes unnecessary files
rm -rf intermediate_ca
mkdir intermediate_ca
cp intermediate.cnf intermediate_ca/
cp spiffe-openssl.cnf intermediate_ca/
pushd intermediate_ca
# Generating the intermediate CA
openssl genrsa -out temp.rsa 2048
openssl pkcs8 -topk8 -in temp.rsa -out intermediate_ca.key -nocrypt
rm temp.rsa
openssl req -key intermediate_ca.key -new -out temp.csr -config intermediate.cnf
openssl x509 -req -days 3650 -in temp.csr -CA "../ca.pem" -CAkey "../ca.key" -CAcreateserial -out intermediate_ca.pem -extfile intermediate.cnf -extensions 'v3_req'
# Generating the leaf and chain
openssl genrsa -out temp.rsa 2048
openssl pkcs8 -topk8 -in temp.rsa -out leaf_signed_by_intermediate.key -nocrypt
openssl req -new -key leaf_signed_by_intermediate.key -out spiffe-cert.csr \
-subj /C=US/ST=CA/L=SVL/O=gRPC/CN=testserver/ \
-config spiffe-openssl.cnf -reqexts spiffe_server_e2e
openssl x509 -req -CA intermediate_ca.pem -CAkey intermediate_ca.key -CAcreateserial \
-in spiffe-cert.csr -out leaf_signed_by_intermediate.pem -extensions spiffe_server_e2e \
-extfile spiffe-openssl.cnf -days 3650 -sha256
cat leaf_signed_by_intermediate.pem intermediate_ca.pem > leaf_and_intermediate_chain.pem
popd
# Copy files up to the higher directory
cp "./intermediate_ca/leaf_signed_by_intermediate.key" ./
cp "./intermediate_ca/leaf_signed_by_intermediate.pem" ./
cp "./intermediate_ca/leaf_and_intermediate_chain.pem" ./
cp "./intermediate_ca/intermediate_ca.key" ./
cp "./intermediate_ca/intermediate_ca.pem" ./
rm ca.srl
rm -rf intermediate_ca