Currently on a single domain, I have hundreds of subdomains, each requiring HTTPS connection.
Needless to say, I hit the 20 certificate/week limit very often
So I created this simple script below, to assist me in creating SAN / UCC certificates.
Each of these SAN / UCC certificates contain up to 100 SSL certificates.
So, 20 of these can give you SSL certificates for 2000 subdomains
Usage is very simple :
- Create a file named domain-list.txt, containing all the subdomains
- Execute this script
Thatβs it
Hope you find it useful.
cheers, HS
#!/bin/bash
# specify the location of Let's Encrypt tool
# with its parameters
certbot='/usr/bin/certbot --agree-tos --email my@email.com --apache --redirect --expand -n '
vhost=( `cat "domain-list.txt" `)
# loop variables
ssl_exec="${certbot}"
n=1
#################### START ##########################
for t in "${vhost[@]}"
do
ssl_exec="${ssl_exec} -d $t "
let "n++"
# every 100th domain, create a SSL certificate
if (( n == 100 )); then
$ssl_exec
#echo $ssl_exec
# reset the loop variables
ssl_exec="${certbot}"
n=1
fi
done
# create SSl certificate for the rest of the domains
#echo $ssl_exec
$ssl_exec