forked from NVIDIA/deepops
-
Notifications
You must be signed in to change notification settings - Fork 1
/
gen-ca.sh
executable file
·28 lines (23 loc) · 921 Bytes
/
gen-ca.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env bash
# Source common libraries and env variables
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
ROOT_DIR="${SCRIPT_DIR}/../.."
source ${ROOT_DIR}/scripts/common.sh
CA_CRT_OUTFILE="${CA_CRT_OUTFILE:-/tmp/ca.crt}"
CA_KEY_OUTFILE="${CA_KEY_OUTFILE:-/tmp/ca.key}"
echo "Generating CA key"
openssl genrsa -des3 -passout pass:foobar -out ${CA_KEY_OUTFILE} 4096
echo "Generating CA certificate"
openssl req -new -x509 -days 1300 -sha256 -key ${CA_KEY_OUTFILE} -out ${CA_CRT_OUTFILE} -passin pass:foobar -subj "/C=US/ST=California/L=Santa Clara/O=DeepOps/OU=HPC/CN=DeepOps" -extensions IA -config <(
cat <<-EOF
[req]
distinguished_name = dn
[dn]
[IA]
basicConstraints = critical,CA:TRUE
keyUsage = critical, digitalSignature, cRLSign, keyCertSign
subjectKeyIdentifier = hash
EOF
)
echo "CA key written out to: ${CA_KEY_OUTFILE}"
echo "CA crt written out to: ${CA_CRT_OUTFILE}"