-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerateKeys.sh
executable file
·68 lines (48 loc) · 1.52 KB
/
generateKeys.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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/bash
# this script generates a set of sample keys
set -e
. structure
. commonFunctions
mkdir -p generated
cd generated
####### create various extensions files for the various certificate types ######
cat <<TESTCA > ca.cnf
basicConstraints = critical,CA:true
keyUsage =critical, keyCertSign, cRLSign
subjectKeyIdentifier = hash
authorityKeyIdentifier = keyid:always
crlDistributionPoints=URI:http://g2.crl.${DOMAIN}/g2/root.crl
authorityInfoAccess = OCSP;URI:http://g2.ocsp.${DOMAIN},caIssuers;URI:http://g2.crt.${DOMAIN}/g2/root.crt
TESTCA
rootSign(){ # csr
POLICY=ca.cnf
if [[ "$1" != "root" ]] ; then
KNAME=$1
POLICY=subca.cnf
. ../CAs/${KNAME}
cat <<TESTCA > subca.cnf
basicConstraints =critical, CA:true
keyUsage =critical, keyCertSign, cRLSign
subjectKeyIdentifier = hash
authorityKeyIdentifier = keyid:always
crlDistributionPoints=URI:http://g2.crl.${DOMAIN}/g2/root.crl
authorityInfoAccess = OCSP;URI:http://g2.ocsp.${DOMAIN},caIssuers;URI:http://g2.crt.${DOMAIN}/g2/root.crt
certificatePolicies=@polsect
[polsect]
policyIdentifier = 1.3.6.1.4.1.18506.9.2.${CPSID}
CPS.1="http://g2.cps.${DOMAIN}/g2/${KNAME}.cps"
TESTCA
fi
caSign "$1.ca/key" root $POLICY
}
# Generate the super Root CA
genca "/CN=Cacert-gigi testCA" root
#echo openssl x509 -req $ROOT_VALIDITY -in root.ca/key.csr -signkey root.ca/key.key -out root.ca/key.crt -extfile ca.cnf
rootSign root
# generate the various sub-CAs
for ca in $STRUCT_CAS; do
. ../CAs/$ca
genca "/CN=$name" $ca
rootSign $ca
done
rm ca.cnf subca.cnf