Instrumental | 31d847e | 2018-03-26 14:17:19 -0700 | [diff] [blame] | 1 | # |
| 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 |
| 10 | DIR=intermediate_$SERIAL |
| 11 | |
| 12 | mkdir -p $DIR/private $DIR/certs $DIR/newcerts |
| 13 | chmod 700 $DIR/private |
| 14 | chmod 755 $DIR/certs $DIR/newcerts |
| 15 | touch $DIR/index.txt |
| 16 | if [ ! -e $DIR/serial ]; then |
| 17 | echo '01' > $DIR/serial |
| 18 | fi |
| 19 | cp manual.sh p12.sh subject.aaf $DIR |
| 20 | |
| 21 | if [ "$1" == "" ]; then |
| 22 | CN=intermediateCA_$SERIAL |
| 23 | else |
| 24 | CN=$1 |
| 25 | fi |
| 26 | |
| 27 | SUBJECT="/CN=$CN`cat subject.aaf`" |
| 28 | echo $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 |
| 40 | EOF |
| 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 | |