initial commit

This commit is contained in:
brent s. 2016-02-22 01:42:47 -05:00
commit b35241f7d0
13 changed files with 381 additions and 0 deletions

6
gen.ca.cert.sh Normal file
View File

@ -0,0 +1,6 @@
#!/bin/bash
set -e

echo "Generating CA certificate..."
openssl req -config ${rootdir}/openssl.cnf -key ${rootdir}/key/ca.key -new -x509 -days 3650 -extensions v3_ca -out ${rootdir}/crt/ca.crt > /dev/null 2>&1
chmod 444 ${rootdir}/crt/ca.crt

6
gen.ca.key.sh Normal file
View File

@ -0,0 +1,6 @@
#!/bin/bash
set -e

echo "Generating CA key..."
openssl genrsa -out ${rootdir}/key/ca.key 4096 > /dev/null 2>&1
chmod 400 ${rootdir}/key/ca.key

6
gen.intermediate.cert.sh Normal file
View File

@ -0,0 +1,6 @@
#!/bin/bash
set -e

echo "Generating intermediate certificate..."
openssl CA -config ${rootdir}/openssl.cnf -days 3650 -extensions v3_ca -notext -md sha512 -in ${rootdir}/intermediate/csr/intermediate.csr -out ${rootdir}/intermediate/crt/intermediate.crt > /dev/null 2>&1
chmod 444 ${rootdir}/intermediate/crt/intermediate.crt

View File

@ -0,0 +1,6 @@
#!/bin/bash
set -e

echo "Generating chain cert file..."
cat ${rootdir}/intermediate/crt/intermediate.crt ${rootdir}/crt/ca.crt > ${rootdir}/intermediate/crt/intermediate-chained.crt
chmod 444 ${rootdir}/intermediate/crt/intermediate-chained.crt

5
gen.intermediate.csr.sh Normal file
View File

@ -0,0 +1,5 @@
#!/bin/bash
set -e

echo "Generating intermediate CSR..."
openssl req -config ${rootdir}/intermediate/openssl.cnf -new -sha512 -key ${rootdir}/intermediate/key/intermediate.key -out ${rootdir}/intermediate/csr/intermediate.csr > /dev/null 2>&1

6
gen.intermediate.key.sh Normal file
View File

@ -0,0 +1,6 @@
#!/bin/bash
set -e

echo "Generating intermediate key..."
openssl genrsa -out ${rootdir}/intermdiate/key/ca.key 4096 > /dev/null 2>&1
chmod 400 ${rootdir}/intermediate/key/ca.key

View File

@ -0,0 +1,6 @@
#!/bin/bash
set -e

echo "Generating certificate (${1})..."
openssl CA -config ${rootdir}/intermediate/openssl.cnf -days 3650 -extensions server_cert -notext -md sha512 -in ${rootdir}/csr/${1}.csr -out ${rootdir}/crt/${1}.crt > /dev/null 2>&1
chmod 444 ${rootdir}/${1}/crt/${1}.crt

View File

@ -0,0 +1,6 @@
#!/bin/bash
set -e

echo "Generating certificate (${1})..."
openssl CA -config ${rootdir}/intermediate/openssl.cnf -days 3650 -extensions usr_cert -notext -md sha512 -in ${rootdir}/csr/${1}.csr -out ${rootdir}/crt/${1}.crt > /dev/null 2>&1
chmod 444 ${rootdir}/crt/${1}.crt

5
gen.serverclient.csr.sh Normal file
View File

@ -0,0 +1,5 @@
#!/bin/bash
set -e

echo "Generating CSR (${1})..."
openssl req -config ${rootdir}/intermediate/openssl.cnf -new -sha512 -key ${rootdir}/key/${1}.key -out ${rootdir}/csr/${1}.csr > /dev/null 2>&1

6
gen.serverclient.key.sh Normal file
View File

@ -0,0 +1,6 @@
#!/bin/bash
set -e

echo "Generating client key (${1})..."
openssl genrsa -out ${rootdir}/key/${1}.key 4096 > /dev/null 2>&1
chmod 400 ${rootdir}/key/${1}.key

148
new.ca.sh Executable file
View File

@ -0,0 +1,148 @@
#!/bin/bash
set -e


rootdir='/root/ssl/ca'
bindir="$(dirname ${0})"
export rootdir
export bindir

echo "If you continue, I will completely DELETE (if found):"
echo " ${rootdir}/key"
echo " ${rootdir}/crt"
echo " ${rootdir}/crl"
echo " ${rootdir}/csr"
echo " ${rootdir}/index.txt"
echo " ${rootdir}/serial"
echo
echo "To continue, type YESIAMCRAZY and hit the enter key."
read RUCRAZY

if [[ "${RUCRAZY}" != 'YESIAMCRAZY' ]];
then
echo '"IAMCRAZY" *NOT* entered. Quitting.'
exit 1
fi

echo "Deleting CA hierarchy and creating clean..."
# https://jamielinux.com/docs/openssl-certificate-authority/create-the-root-pair.html
rm -rf ${rootdir}/{key,crt,crl,csr,index.txt,serial}
mkdir -p ${rootdir}/{key,crt,crl,csr}
echo '1000' > ${rootdir}/serial
touch ${rootdir}/index.txt
chmod 700 ${rootdir}
chmod 700 ${rootdir}/key



base64 -d >> ${rootdir}/openssl.cnf << EOF
IyBPcGVuU1NMIHJvb3QgQ0EgY29uZmlndXJhdGlvbiBmaWxlLgojIGh0dHBzOi8vamFtaWVsaW51
eC5jb20vZG9jcy9vcGVuc3NsLWNlcnRpZmljYXRlLWF1dGhvcml0eS9jcmVhdGUtdGhlLXJvb3Qt
cGFpci5odG1sCgpbIGNhIF0KIyBgbWFuIGNhYApkZWZhdWx0X2NhID0gQ0FfZGVmYXVsdAoKWyBD
QV9kZWZhdWx0IF0KIyBEaXJlY3RvcnkgYW5kIGZpbGUgbG9jYXRpb25zLgpkaXIgICAgICAgICAg
ICAgICA9ICUlVEVNUExBVEVfUk9PVERJUiUlCmNlcnRzICAgICAgICAgICAgID0gJGRpci9jcnQK
Y3JsX2RpciAgICAgICAgICAgPSAkZGlyL2NybApuZXdfY2VydHNfZGlyICAgICA9ICRkaXIvY3J0
CmRhdGFiYXNlICAgICAgICAgID0gJGRpci9pbmRleC50eHQKc2VyaWFsICAgICAgICAgICAgPSAk
ZGlyL3NlcmlhbApSQU5ERklMRSAgICAgICAgICA9ICRkaXIva2V5Ly5yYW5kCgojIFRoZSByb290
IGtleSBhbmQgcm9vdCBjZXJ0aWZpY2F0ZS4KcHJpdmF0ZV9rZXkgICAgICAgPSAkZGlyL2tleS9j
YS5rZXkKY2VydGlmaWNhdGUgICAgICAgPSAkZGlyL2NydC9jYS5jcnQKCiMgRm9yIGNlcnRpZmlj
YXRlIHJldm9jYXRpb24gbGlzdHMuCmNybG51bWJlciAgICAgICAgID0gJGRpci9jcmxudW1iZXIK
Y3JsICAgICAgICAgICAgICAgPSAkZGlyL2NybC9jYS5jcmwKY3JsX2V4dGVuc2lvbnMgICAgPSBj
cmxfZXh0CmRlZmF1bHRfY3JsX2RheXMgID0gMzAKCiMgU0hBLTEgaXMgZGVwcmVjYXRlZCwg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bmF0dXJlLCBrZXlFbmNpcGhlcm1lbnQKZXh0ZW5kZWRLZXlVc2FnZSA9
IHNlcnZlckF1dGgKClsgY3JsX2V4dCBdCiMgRXh0ZW5zaW9uIGZvciBDUkxzIChgbWFuIHg1MDl2
M19jb25maWdgKS4KYXV0aG9yaXR5S2V5SWRlbnRpZmllcj1rZXlpZDphbHdheXMKClsgb2NzcCBd
CiMgRXh0ZW5zaW9uIGZvciBPQ1NQIHNpZ25pbmcgY2VydGlmaWNhdGVzIChgbWFuIG9jc3BgKS4K
YmFzaWNDb25zdHJhaW50cyA9IENBOkZBTFNFCnN1YmplY3RLZXlJZGVudGlmaWVyID0gaGFzaAph
dXRob3JpdHlLZXlJZGVudGlmaWVyID0ga2V5aWQsaXNzdWVyCmtleVVzYWdlID0gY3JpdGljYWws
IGRpZ2l0YWxTaWduYXR1cmUKZXh0ZW5kZWRLZXlVc2FnZSA9IGNyaXRpY2FsLCBPQ1NQU2lnbmlu
ZwoK
EOF

echo "Customizing openssl.cnf..."
echo
echo -n "What is your ORGANIZATION'S name? "
read ORGNAME
export ORGNAME
echo -n "And what is your organization's MAIN DOMAIN? "
read ORGSITE
export ORGSITE
echo -n "What Country (two-letter abbreviation) is your organization locatied in? "
read ORGCNTRY
export ORGCNTRY
echo -n "What State (full name) is your organization located in? "
read ORGSTATE
export ORGSTATE
echo -n "What City is your organization located in? "
read ORGCITY
export ORGCITY
echo -n "Lastly, what email address should be used for the SSL administrator? "
read SSLADMIN
export SSLADMIN

sed -i -e "s/%%TEMPLATE_ORG%%/${ORGNAME}/g ; s/%%TEMPLATE_DOMAIN%%/${ORGSITE}/g ; s/%%TEMPLATE_ROOTDIR%%/${rootdir}/g ; s/%%TEMPLATE_COUNTRY%%/${ORGCNTRY}/g ; s/%%TEMPLATE_STATE%%/${ORGSTATE}/g ; s/%%TEMPLATE_CITY%%/${ORGCITY}/g ; s/%%TEMPLATE_SSLADMIN%%/${SSLADMIN}/g" ${rootdir}/openssl.cnf

NEWCA='yes'
export NEWCA

sh ${bindir}/gen.ca.key.sh
sh ${bindir}/gen.ca.cert.sh
sh ${bindir}/new.intermediate.sh
sh ${bindir}/new.serverclient.sh ${ORGSITE}

154
new.intermediate.sh Normal file
View File

@ -0,0 +1,154 @@
#!/bin/bash
set -e


if [[ -z "${NEWCA}" ]];
then

rootdir='/root/ssl/ca'
bindir="$(dirname ${0})"
export rootdir
export bindir

echo "If you continue, I will completely DELETE (if found):"
echo " ${rootdir}/intermediate/key"
echo " ${rootdir}/intermediate/crt"
echo " ${rootdir}/intermediate/crl"
echo " ${rootdir}/intermediate/csr"
echo " ${rootdir}/intermediate/index.txt"
echo " ${rootdir}/intermediate/serial"
echo
echo "To continue, type YESIAMCRAZY and hit the enter key."
read RUCRAZY2
else
RUCRAZY2='YESIAMCRAZY'
fi

if [[ "${RUCRAZY2}" != 'YESIAMCRAZY' ]];
then
echo '"IAMCRAZY" *NOT* entered. Quitting.'
exit 1
fi


echo "Deleting intermediary hierarchy and creating clean..."
rm -rf ${rootdir}/intermediate/{key,crt,crl,csr,index.txt,serial}
mkdir -p ${rootdir}/intermediate/{key,crt,crl,csr}
echo '1000' > ${rootdir}/intermediate/serial
touch ${rootdir}/intermediate/index.txt
chmod 700 ${rootdir}/intermediate
chmod 700 ${rootdir}/intermediate/key
echo 1000 > ${rootdir}/intermediate/crlnumber



base64 -d >> ${rootdir}/intermediate/openssl.cnf << EOF
IyBPcGVuU1NMIGludGVybWVkaWF0ZSBDQSBjb25maWd1cmF0aW9uIGZpbGUuCiMgQ29weSB0byBg
L3Jvb3QvY2EvaW50ZXJtZWRpYXRlL29wZW5zc2wuY25mYC4KClsgY2EgXQojIGBtYW4gY2FgCmRl
ZmF1bHRfY2EgPSBDQV9kZWZhdWx0CgpbIENBX2RlZmF1bHQgXQojIERpcmVjdG9yeSBhbmQgZmls
ZSBsb2NhdGlvbnMuCmRpciAgICAgICAgICAgICAgID0gJSVURU1QTEFURV9ST09URElSJSUvaW50
ZXJtZWRpYXR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bnRpZmllciA9IGhhc2gKYXV0aG9yaXR5S2V5SWRlbnRp
ZmllciA9IGtleWlkLGlzc3VlcgprZXlVc2FnZSA9IGNyaXRpY2FsLCBkaWdpdGFsU2lnbmF0dXJl
CmV4dGVuZGVkS2V5VXNhZ2UgPSBjcml0aWNhbCwgT0NTUFNpZ25pbmcKCg==
EOF

if [[ -z ${NEWCA} ]];
then
echo "Customizing openssl.cnf..."
echo
echo -n "What is your ORGANIZATION'S name? "
read ORGNAME
export ORGNAME
echo -n "And what is your organization's MAIN DOMAIN? "
read ORGSITE
export ORGSITE
echo -n "What Country (two-letter abbreviation) is your organization locatied in? "
read ORGCNTRY
export ORGCNTRY
echo -n "What State (full name) is your organization located in? "
read ORGSTATE
export ORGSTATE
echo -n "What City is your organization located in? "
read ORGCITY
export ORGCITY
echo -n "Lastly, what email address should be used for the SSL administrator? "
read SSLADMIN
export SSLADMIN
fi

sed -i -e "s/%%TEMPLATE_ORG%%/${ORGNAME}/g ; s/%%TEMPLATE_DOMAIN%%/${ORGSITE}/g ; s/%%TEMPLATE_ROOTDIR%%/${rootdir}/g ; s/%%TEMPLATE_COUNTRY%%/${ORGCNTRY}/g ; s/%%TEMPLATE_STATE%%/${ORGSTATE}/g ; s/%%TEMPLATE_CITY%%/${ORGCITY}/g ; s/%%TEMPLATE_SSLADMIN%%/${SSLADMIN}/g" ${rootdir}/intermediate/openssl.cnf

sh ${bindir}/gen.intermediate.key.sh
sh ${bindir}/gen.intermediate.csr.sh
sh ${bindir}/gen.intermediate.cert.sh
sh ${bindir}/gen.intermediate.chain.sh

21
new.serverclient.sh Normal file
View File

@ -0,0 +1,21 @@
#!/bin/bash
set -e

if [[ -n "${1}" ]];
then
CN=${1}
export CN
else
echo "You need to provide a CN name!"
echo "e.g. ${0} someCNhere"
echo "(You probably want the domain/subdomain there)"
exit 1
fi



sh ${bindir}/gen.serverclient.key.sh ${CN}
sh ${bindir}/gen.serverclient.csr.sh ${CN}
sh ${bindir}/gen.serverclient.cert-server.sh ${CN}
#sh ${bindir}/gen.serverclient.cert-user.sh ${CN}
sh ${bindir}/gen.serverclient.chain.sh ${CN}