Debian Codegraph @

crt/s2n/tests/pems/san_with_ca/generate.sh

raw symbols SCIP
1 #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash
2
3 # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
4 # SPDX-License-Identifier: Apache-2.0
5
6 # immediately bail if any command fails
7 set -e
8
9 echoscip-shell system . . echo. "generating CA"
10 opensslscip-shell system . . openssl. req -new -noenc -x509 \
11 -newkey ec \
12 -pkeyopt ec_paramgen_curve:P-384 \
13 -keyout ca-key.pem \
14 -out ca-cert.pem \
15 -days 65536 \
16 -SHA256 \
17 -subj "/C=US/CN=rootscip-shell filesystem . . `/C=US/CN=root`." \
18 -addext "basicConstraints = critical,CA:true" \
19 -addext "keyUsage = critical,keyCertSign"
20
21 echoscip-shell system . . echo. "generating server private key and CSR"
22 opensslscip-shell system . . openssl. req -new -noenc \
23 -newkey ec \
24 -pkeyopt ec_paramgen_curve:P-384 \
25 -keyout kitten-key.pem \
26 -out kitten.csr \
27 -subj "/C=US/CN=kittenscip-shell filesystem . . `/C=US/CN=kitten`." \
28 -addext "subjectAltName = DNS:www.kitten.com"
29
30 echoscip-shell system . . echo. "generating server certificate and signing it"
31 opensslscip-shell system . . openssl. x509 -days 65536 \
32 -req -in kitten.csr \
33 -SHA256 \
34 -CA ca-cert.pem \
35 -CAkey ca-key.pem \
36 -CAcreateserial \
37 -out kitten-cert.pem \
38 -copy_extensions=copyall
39
40 touchscip-shell system . . touch. kitten-chain.pem
41 catscip-shell system . . cat. kitten-cert.pem >> kitten-chain.pem
42 catscip-shell system . . cat. ca-cert.pem >> kitten-chain.pem
43
44 echoscip-shell system . . echo. "verifying server certificates"
45 opensslscip-shell system . . openssl. verify -CAfile ca-cert.pem kitten-cert.pem
46
47 # certificate signing requests are never used after the certs are generated
48 rmscip-shell system . . rm. kitten.csr
49 rmscip-shell system . . rm. ca-cert.srl
50
51 # the private keys of the CA are never needed after signing
52 rmscip-shell system . . rm. ca-key.pem
53 rmscip-shell system . . rm. ca-cert.pem
54 rmscip-shell system . . rm. kitten-cert.pem
55