Debian Codegraph @

crt/s2n/bindings/rust-examples/certs/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 -SHA384 \
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 wombat private key and CSR"
22 opensslscip-shell system . . openssl. req -new -noenc \
23 -newkey ec \
24 -pkeyopt ec_paramgen_curve:P-384 \
25 -keyout wombat-key.pem \
26 -out wombat.csr \
27 -subj "/C=US/CN=wombatscip-shell filesystem . . `/C=US/CN=wombat`." \
28 -addext "subjectAltName = DNS:www.wombat.com"
29
30 echoscip-shell system . . echo. "generating kangaroo private key and CSR"
31 opensslscip-shell system . . openssl. req -new -noenc \
32 -newkey ec \
33 -pkeyopt ec_paramgen_curve:P-384 \
34 -keyout kangaroo-key.pem \
35 -out kangaroo.csr \
36 -subj "/C=US/CN=kangarooscip-shell filesystem . . `/C=US/CN=kangaroo`." \
37 -addext "subjectAltName = DNS:www.kangaroo.com"
38
39 echoscip-shell system . . echo. "generating localhost private key and CSR"
40 opensslscip-shell system . . openssl. req -new -noenc \
41 -newkey ec \
42 -pkeyopt ec_paramgen_curve:P-384 \
43 -keyout localhost-key.pem \
44 -out localhost.csr \
45 -subj "/C=US/CN=localhostscip-shell filesystem . . `/C=US/CN=localhost`." \
46 -addext "subjectAltName = DNS:localhost"
47
48 echoscip-shell system . . echo. "generating wombat server certificate and signing it"
49 opensslscip-shell system . . openssl. x509 -days 65536 \
50 -req -in wombat.csr \
51 -SHA384 \
52 -CA ca-cert.pem \
53 -CAkey ca-key.pem \
54 -CAcreateserial \
55 -out wombat-cert.pem \
56 -copy_extensions=copyall
57
58 echoscip-shell system . . echo. "generating kangaroo certificate and signing it"
59 opensslscip-shell system . . openssl. x509 -days 65536 \
60 -req -in kangaroo.csr \
61 -SHA384 \
62 -CA ca-cert.pem \
63 -CAkey ca-key.pem \
64 -CAcreateserial \
65 -out kangaroo-cert.pem \
66 -copy_extensions=copyall
67
68 echoscip-shell system . . echo. "generating localhost certificate and signing it"
69 opensslscip-shell system . . openssl. x509 -days 65536 \
70 -req -in localhost.csr \
71 -SHA384 \
72 -CA ca-cert.pem \
73 -CAkey ca-key.pem \
74 -CAcreateserial \
75 -out localhost-cert.pem \
76 -copy_extensions=copyall
77
78 touchscip-shell system . . touch. wombat-chain.pem
79 catscip-shell system . . cat. wombat-cert.pem >> wombat-chain.pem
80 catscip-shell system . . cat. ca-cert.pem >> wombat-chain.pem
81
82 touchscip-shell system . . touch. kangaroo-chain.pem
83 catscip-shell system . . cat. kangaroo-cert.pem >> kangaroo-chain.pem
84 catscip-shell system . . cat. ca-cert.pem >> kangaroo-chain.pem
85
86 touchscip-shell system . . touch. localhost-chain.pem
87 catscip-shell system . . cat. localhost-cert.pem >> localhost-chain.pem
88 catscip-shell system . . cat. ca-cert.pem >> localhost-chain.pem
89
90 echoscip-shell system . . echo. "verifying server certificates"
91 opensslscip-shell system . . openssl. verify -CAfile ca-cert.pem wombat-cert.pem
92 opensslscip-shell system . . openssl. verify -CAfile ca-cert.pem kangaroo-cert.pem
93 opensslscip-shell system . . openssl. verify -CAfile ca-cert.pem localhost-cert.pem
94
95 # certificate signing requests are never used after the certs are generated
96 rmscip-shell system . . rm. wombat.csr
97 rmscip-shell system . . rm. kangaroo.csr
98 rmscip-shell system . . rm. localhost.csr
99 rmscip-shell system . . rm. ca-cert.srl
100
101 # the private keys of the CA are never needed after signing
102 rmscip-shell system . . rm. ca-key.pem
103 rmscip-shell system . . rm. wombat-cert.pem
104 rmscip-shell system . . rm. kangaroo-cert.pem
105 rmscip-shell system . . rm. localhost-cert.pem
106