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 | echo "FQI (Fully Qualified Identity): " |
| 5 | read FQI |
| 6 | if [ "$1" = "" -o "$1" = "-local" ]; then |
| 7 | echo "Personal Certificate" |
| 8 | SUBJECT="/CN=$FQI/OU=V1`cat subject.aaf`" |
Instrumental | 97083ef | 2018-04-25 15:22:38 -0500 | [diff] [blame] | 9 | NAME=$FQI |
Instrumental | 31d847e | 2018-03-26 14:17:19 -0700 | [diff] [blame] | 10 | else |
| 11 | echo "Application Certificate" |
| 12 | SUBJECT="/CN=$1/OU=$FQI`cat subject.aaf`" |
Instrumental | 97083ef | 2018-04-25 15:22:38 -0500 | [diff] [blame] | 13 | FQDN=$1 |
| 14 | NAME=$FQDN |
Instrumental | 31d847e | 2018-03-26 14:17:19 -0700 | [diff] [blame] | 15 | shift |
| 16 | fi |
| 17 | echo $SUBJECT |
| 18 | |
| 19 | if [ -e $FQI.csr ]; then |
| 20 | SIGN_IT=true |
| 21 | else |
| 22 | if [ "$1" = "-local" ]; then |
| 23 | echo "IMPORTANT: If for any reason, you kill this process, type 'stty sane'" |
| 24 | echo "Enter the PassPhrase for the Key for $FQI: " |
| 25 | `stty -echo` |
| 26 | read PASSPHRASE |
| 27 | `stty echo` |
| 28 | |
| 29 | # remove any previous Private key |
Instrumental | 97083ef | 2018-04-25 15:22:38 -0500 | [diff] [blame] | 30 | rm private/$NAME.key |
Instrumental | 31d847e | 2018-03-26 14:17:19 -0700 | [diff] [blame] | 31 | # Create j regaular rsa encrypted key |
Instrumental | 97083ef | 2018-04-25 15:22:38 -0500 | [diff] [blame] | 32 | openssl req -new -newkey rsa:2048 -sha256 -keyout private/$NAME.key \ |
| 33 | -out $NAME.csr -outform PEM -subj "$SUBJECT" \ |
Instrumental | 31d847e | 2018-03-26 14:17:19 -0700 | [diff] [blame] | 34 | -passout stdin << EOF |
| 35 | $PASSPHRASE |
| 36 | EOF |
Instrumental | 97083ef | 2018-04-25 15:22:38 -0500 | [diff] [blame] | 37 | chmod 400 private/$NAME.key |
Instrumental | 31d847e | 2018-03-26 14:17:19 -0700 | [diff] [blame] | 38 | SIGN_IT=true |
| 39 | else |
Instrumental | 97083ef | 2018-04-25 15:22:38 -0500 | [diff] [blame] | 40 | echo openssl req -newkey rsa:2048 -sha256 -keyout $NAME.key -out $NAME.csr -outform PEM -subj '"'$SUBJECT'"' |
| 41 | echo chmod 400 $NAME.key |
Instrumental | 31d847e | 2018-03-26 14:17:19 -0700 | [diff] [blame] | 42 | echo "# All done, print result" |
Instrumental | 97083ef | 2018-04-25 15:22:38 -0500 | [diff] [blame] | 43 | echo openssl req -verify -text -noout -in $NAME.csr |
Instrumental | 31d847e | 2018-03-26 14:17:19 -0700 | [diff] [blame] | 44 | fi |
| 45 | fi |
| 46 | |
| 47 | if [ "$SIGN_IT" = "true" ]; then |
| 48 | # Sign it |
Instrumental | 97083ef | 2018-04-25 15:22:38 -0500 | [diff] [blame] | 49 | openssl ca -config ../openssl.conf -extensions server_cert -out $NAME.crt \ |
Instrumental | 31d847e | 2018-03-26 14:17:19 -0700 | [diff] [blame] | 50 | -cert certs/ca.crt -keyfile private/ca.key \ |
Instrumental | 924b18d | 2018-04-05 20:17:18 -0500 | [diff] [blame] | 51 | -policy policy_loose \ |
| 52 | -days 360 \ |
Instrumental | 97083ef | 2018-04-25 15:22:38 -0500 | [diff] [blame] | 53 | -infiles $NAME.csr |
Instrumental | 31d847e | 2018-03-26 14:17:19 -0700 | [diff] [blame] | 54 | fi |
| 55 | |
| 56 | |
| 57 | |
| 58 | |