blob: b20715040a99eb23441d08fa87b8dc2d34ae6eb5 [file] [log] [blame]
Instrumental31d847e2018-03-26 14:17:19 -07001#
2# Initialize a manual Cert. This is NOT entered in Certman Records
3#
4 if [ -e intermediate.serial ]; then
5 ((SERIAL=`cat intermediate.serial` + 1))
6 else
7 SERIAL=1
8 fi
9 echo $SERIAL > intermediate.serial
10DIR=intermediate_$SERIAL
11
12mkdir -p $DIR/private $DIR/certs $DIR/newcerts
13chmod 700 $DIR/private
14chmod 755 $DIR/certs $DIR/newcerts
15touch $DIR/index.txt
16if [ ! -e $DIR/serial ]; then
17 echo '01' > $DIR/serial
18fi
19cp manual.sh p12.sh subject.aaf $DIR
20
21if [ "$1" == "" ]; then
22 CN=intermediateCA_$SERIAL
23else
24 CN=$1
25fi
26
27SUBJECT="/CN=$CN`cat subject.aaf`"
28echo $SUBJECT
29 echo "IMPORTANT: If for any reason, you kill this process, type 'stty sane'"
30 echo "Enter the PassPhrase for the Key for $CN: "
31 `stty -echo`
32 read PASSPHRASE
33 `stty echo`
34
35 # Create a regaular rsa encrypted key
36 openssl req -new -newkey rsa:4096 -sha256 -keyout $DIR/private/ca.key \
37 -out $DIR/$CN.csr -outform PEM -subj "$SUBJECT" \
38 -passout stdin << EOF
39$PASSPHRASE
40EOF
41
42 chmod 400 $DIR/private/$CN.key
43 openssl req -verify -text -noout -in $DIR/$CN.csr
44
45 # Sign it
46 openssl ca -config openssl.conf -extensions v3_intermediate_ca \
47 -cert certs/ca.crt -keyfile private/ca.key -out $DIR/certs/ca.crt \
48 -infiles $DIR/$CN.csr
49
50 openssl x509 -text -noout -in $DIR/certs/ca.crt
51
52
53 openssl verify -CAfile certs/ca.crt $DIR/certs/ca.crt
54
55
56
57