I’m currently using namecheap.com for hosting. When joining, they give you a free one year SSL certificate. After that, they make it quite easy to buy another 1 year SSL certificate for $34.95 for each domain. Currently have five domains. This is not cost effective.
Since I have ssh access on my namecheap accounts (or cPanel>Terminal) it was pretty easy to set up free SSL indefinitely. A no-code approach is to use cloudflare.com where they have a free autorenew SSL option.
There is a pure bash script, hosted and maintained by ZeroSSL called acme.sh This can issue, deploy and renew SSL automatically. To start, on the root directory of your host account, issue the following commands in Terminal:
curl https://get.acme.sh | sh -s email=you@example.com source ~/.bashrc
where the first line downloads a sh script and executes it. Everything is set up in ${HOME}/.acme.sh. It also sets the email address to inform you of any problems. This should be a valid email you use so if acme.sh runs into trouble, you’ll know to take action. The second line just sources the current Terminal. You could simply open a new Terminal instead. Regardless, either one must be done.
I used Let’s Encrypt for free SSL. So, we do the following in Terminal:
acme.sh --set-default-ca --server letsencrypt
And now we need to issue a new SSL certificate:
acme.sh --issue -d yourdomain.com -d www.yourdomain.com -w ${HOME}/public_html
where yourdomain.com is your domain name and ${HOME}/public_html is the root directory of yourdomain.com on the server. Assuming the above completes with no errors, you can now deploy the new SSL:
acme.sh --deploy -d yourdomain.com --deploy-hook cpanel_uapi
If you have multiple domains on the same host, then a similar
acme.sh --issue -d seconddomain.com -d www.seconddomain.com -w ${HOME}/public_html/seconddomain.com
acme.sh --deploy -d seconddomain.com --deploy-hook cpanel_uapi
where ${HOME}/public_html/seconddomain.com is the root directory of secconddomain.com.
acme.sh will automatically set up a crontab entry to check if any SSL is about to expire. If so, it automatically renews for you. In Terminal
crontab -l
should return something like
54 5,11,17,23 * * * "${HOME}/.acme.sh"/acme.sh --cron --home "${HOME}/.acme.sh" > /dev/null
where the numbers in the left will change, but you see acme.sh will be executed (note: ${HOME} will be your actual home directory) periodically (here, four times daily!). It will scan all the domains you have used acme.sh to setup up SSL.
Add a Comment