2 # Streamlined AAF Bootstrap initial Cert
3 # Removed Variables so it can be run for AutoDeployments
5 echo "Bootstrap AAF Certificate"
6 mkdir -p private certs newcerts
8 chmod 755 certs newcerts
10 echo "unique_subject = no" > index.txt.attr
11 if [ ! -e ./serial ]; then
18 SUBJECT="/CN=$FQDN/OU=$FQI`cat subject.aaf`"
20 SIGNER_KEY=/tmp/aaf_signer.key
21 SIGNER_CRT=/tmp/aaf_signer.crt
23 if [ "PASSPHRASE" = "" ]; then
24 PASSPHRASE="something easy"
26 BOOTSTRAP_SAN=/tmp/$NAME.san
27 BOOTSTRAP_KEY=/tmp/$NAME.key
28 BOOTSTRAP_CSR=/tmp/$NAME.csr
29 BOOTSTRAP_CRT=/tmp/$NAME.crt
30 BOOTSTRAP_CHAIN=/tmp/$NAME.chain
31 BOOTSTRAP_P12=$NAME.p12
34 # If Signer doesn't exist, create Self-Signed CA
35 if [ ! -e "$SIGNER_P12" ]; then
37 openssl req -config openssl.conf -x509 -sha256 -extensions v3_ca \
38 -newkey rsa:4096 -subj /CN="Signer$(cat subject.aaf)" \
39 -keyout $SIGNER_KEY -out $SIGNER_CRT -days 365 -passout stdin << EOF
43 # Move to P12 (Signer)
44 openssl pkcs12 -name RootCA -export -in $SIGNER_CRT -inkey $SIGNER_KEY -out $SIGNER_P12 -passin stdin -passout stdin << EOF
51 # Get Private key from P12
52 openssl pkcs12 -in $SIGNER_P12 -nocerts -nodes -passin stdin -passout stdin -out $SIGNER_KEY << EOF
58 openssl pkcs12 -in $SIGNER_P12 -clcerts -nokeys -passin stdin -out $SIGNER_CRT << EOF
65 cp san.conf $BOOTSTRAP_SAN
67 for D in $FQDN aaf.osaaf.org service.aaf.osaaf.org locate.aaf.osaaf.org oauth.aaf.osaaf.org gui.aaf.osaaf.org cm.aaf.osaaf.org hello.aaf.osaaf.org; do
68 echo "DNS.$NUM = $D" >> $BOOTSTRAP_SAN
73 openssl req -new -newkey rsa:2048 -nodes -keyout $BOOTSTRAP_KEY \
74 -out $BOOTSTRAP_CSR -outform PEM -subj "$SUBJECT" \
80 openssl ca -batch -config openssl.conf -extensions server_cert \
81 -cert $SIGNER_CRT -keyfile $SIGNER_KEY \
82 -policy policy_loose \
86 -extfile $BOOTSTRAP_SAN \
87 -infiles $BOOTSTRAP_CSR << EOF
92 # Add THIS Intermediate CA into chain
94 cp $BOOTSTRAP_CRT $BOOTSTRAP_CHAIN
95 cat $SIGNER_CRT >> $BOOTSTRAP_CHAIN
97 # Note: Openssl will pickup and load all Certs in the Chain file
98 openssl pkcs12 -name $FQI -export -in $BOOTSTRAP_CHAIN -inkey $BOOTSTRAP_KEY -out $BOOTSTRAP_P12 -passin stdin -passout stdin << EOF
105 rm -f $BOOTSTRAP_SAN $BOOTSTRAP_KEY $BOOTSTRAP_CSR $BOOTSTRAP_CRT $BOOTSTRAP_CHAIN $SIGNER_KEY $SIGNER_CRT