blob: 5f49f38af5c205f916730edfa8ac289c06e0763c [file] [log] [blame]
Instrumental31d847e2018-03-26 14:17:19 -07001#
2# NOTE: This README is "bash" capable. bash README.txt
3#
4# create simple but reasonable directory structure
5mkdir -p private certs newcerts
6chmod 700 private
7chmod 755 certs newcerts
8touch index.txt
9if [ ! -e serial ]; then
10 echo '01' > serial
11fi
12
13if [ "$1" == "" ]; then
14 CN=$1
15else
16 CN=RootCA
17fi
18
19echo "IMPORTANT: If for any reason, you kill this process, type 'stty sane'"
20echo "Enter the PassPhrase for your Key: "
21`stty -echo`
22read PASSPHRASE
23`stty echo`
24
25if [ ! -e /private/ca.ekey ]; then
26 # Create a regaular rsa encrypted key
27 openssl genrsa -aes256 -out private/ca.ekey -passout stdin 4096 << EOF
28$PASSPHRASE
29EOF
30fi
31
32if [ ! -e /private/ca.key ]; then
33 # Move to a Java/Filesystem readable key. Note that this one is NOT Encrypted.
34 openssl pkcs8 -in private/ca.ekey -topk8 -nocrypt -out private/ca.key -passin stdin << EOF
35$PASSPHRASE
36EOF
37fi
38chmod 400 private/ca.key private/ca.ekey
39
40
41if [ -e subject.aaf ]; then
42 SUBJECT="-subj /CN=$CN`cat subject.aaf`"
43else
44 SUBJECT=""
45fi
46
47# Generate a CA Certificate
48openssl req -config openssl.conf \
49 -key private/ca.key \
50 -new -x509 -days 7300 -sha256 -extensions v3_ca \
51 $SUBJECT \
52 -out certs/ca.crt
53
54if [ -e certs/ca.crt ]; then
55 # All done, print result
56 openssl x509 -text -noout -in certs/ca.crt
57fi