Are you using Let’s Encrypt as your CA (certificate authority) to issue you a trusted certificate for your own domain? Sometimes forgetting to renew when it expires every 90 days? Keep getting email warning you about the expiry date of your SSL certificate? or find out the hard way by getting email about the complain of your site not being able to access due to the expired SSL certificate? You are in luck, in this short tutorial, I am going to show you guys how to make Let’s Encrypt renewal automatic. So that you will never have to worry about it ever again.

I assume that you have shell access to your hosting server, so that you can create cron job as well as executing simple Bash script to do the trick.

Renewing Let’s Encrypt is actually pretty easy. Thanks for Let’s Encrypt for making it so easy. You simply need to run this command to do the renewal.

  cd letsencrypt/; ./letsencrypt-auto renew

source code hosted on GitHub

Next, you need to make a simple bash script that include the line above so that cron job can run.

This is the bash script that I have on my server.

  #!/bin/bash
  now="$(date)"
  printf "Current date and time %s\n" "$now"
  cd letsencrypt/; ./letsencrypt-auto renew

source code hosted on GitHub

I have also created a file named readmeForLetsEncrypt.log so that I get the run-result in case something went wrong that I can use for debugging purpose.

This is how I configure my cron job.

  0 0 1 * * cd /path/to/your/folder; ./readmeForLetsEncrypt.sh > readmeForLetsEncrypt.log

This cron job will run every 1st of the month (you probably don’t need to run it once a month but there should be no harm for doing it regularly). Every 3 months before the certificate expired should work. Combining these two, you should have the Let’s Encrypt certificate renewal automated. Follow this guide in case you accidentally deleted all your cron jobs. Yes, it happened on me before…

Whoa.

Okay, do let me know in the comments below if you have any questions/concerns and I would be happy to help in any way. Good luck in automating your Let’s Encrypt renewal process.

Wrapping Up

Hopefully you enjoyed this short tutorial. Let me know if this helps you. Thank you for reading!

Resources

I’ll try to keep this list current and up to date. If you know of a great resource you’d like to share or notice a broken link, please let us know.

Getting started