Skip to content
Snippets Groups Projects
Commit 73883759 authored by Stefan Galinski's avatar Stefan Galinski :video_game:
Browse files

[FEATURE] Creation of SSL certificates for all(!) server names inside a single certificate

parent 0d050e4b
No related branches found
No related tags found
No related merge requests found
...@@ -279,7 +279,7 @@ bash 'Create Certificate' do ...@@ -279,7 +279,7 @@ bash 'Create Certificate' do
cwd '/etc/apache2/ssl/' cwd '/etc/apache2/ssl/'
code <<-EOF code <<-EOF
chmod 755 create_certificate_for_domain.sh chmod 755 create_certificate_for_domain.sh
./create_certificate_for_domain.sh #{node['typo3_site']['hostname']} ./create_certificate_for_domain.sh #{node['typo3_site']['hostname']} #{node['typo3_site']['server_aliases']}
EOF EOF
action :run action :run
end end
......
#!/usr/bin/env bash #!/usr/bin/env bash
if [ -z "$1" ] if [ -z "$1" ]
then then
echo "Please supply a subdomain to create a certificate for"; echo "Please supply at least one subdomain to create a certificate for";
echo "e.g. www.mysite.com" echo "e.g. www.example.com"
exit; exit;
fi fi
...@@ -15,15 +15,24 @@ fi ...@@ -15,15 +15,24 @@ fi
DOMAIN=$1 DOMAIN=$1
COMMON_NAME=${2:-*.$1} COMMON_NAME=${2:-*.$1}
SUBJECT="/C=CA/ST=None/L=NB/O=None/CN=$COMMON_NAME" SUBJECT="/C=CA/ST=None/L=NB/O=None/CN=${COMMON_NAME}"
NUM_OF_DAYS=999 NUM_OF_DAYS=999
openssl req -new -newkey rsa:2048 -sha256 -nodes $KEY_OPT device.key -subj "$SUBJECT" -out device.csr openssl req -new -newkey rsa:2048 -sha256 -nodes ${KEY_OPT} device.key -subj "${SUBJECT}" -out device.csr
cat v3.ext | sed s/%%DOMAIN%%/$COMMON_NAME/g > /tmp/__v3.ext
openssl x509 -req -in device.csr -CA rootCA.pem -CAkey rootCA.key -CAcreateserial -out device.crt -days $NUM_OF_DAYS -sha256 -extfile /tmp/__v3.ext cp v3.ext /tmp/__v3.ext
DOMAIN_COUNTER=1
for domain_in_list in "$@"
do
echo "DNS.${DOMAIN_COUNTER} = ${domain_in_list}" >> /tmp/__v3.ext
((DOMAIN_COUNTER++))
done
#cat v3.ext | sed s/%%DOMAIN%%/${COMMON_NAME}/g > /tmp/__v3.ext
openssl x509 -req -in device.csr -CA rootCA.pem -CAkey rootCA.key -CAcreateserial -out device.crt -days ${NUM_OF_DAYS} -sha256 -extfile /tmp/__v3.ext
# move output files to final filenames # move output files to final filenames
mv device.csr $DOMAIN.csr mv device.csr ${DOMAIN}.csr
cp device.crt $DOMAIN.crt cp device.crt ${DOMAIN}.crt
# remove temp file # remove temp file
rm -f device.crt; rm -f device.crt;
......
...@@ -4,4 +4,3 @@ keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment ...@@ -4,4 +4,3 @@ keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment
subjectAltName = @alt_names subjectAltName = @alt_names
[alt_names] [alt_names]
DNS.1 = %%DOMAIN%%
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment