How could I automate the generation of SSL certificates for different subdomains? In my workflow, different subdomains ab.mydomain.com, cd.mydomain.com, ab.mynewdomain.com, etc. will point to the IP of my Nginx machine.
I want to generate SSL certificates for these subdomains configured on my Nginx. How could I automate the generation of SSL certificates? Is there a way? Is there any library that can do this for me? I can also start with free SSL certificates, that will not be a problem.
I tried to search this, but could not find any answer.
Admiral Noisy Bottom is right, LetsEncrypt can generate valid certificates for you, and certbot is one of the easiest ways to do that.
You can find certbot instructions here which differ slightly for each platform.
Certbot will make the changes to your nginx configuration for you, if you run:
You may need to answer some questions the first time you run it, but for future renewals it will be automatic.
(You might want to back up your nginx config first! But I've never had a problem with it.)
Don't forget to follow their instructions at the end of the process, to add a cronjob for automatic renewal.
One mistake I have in the past was to use
crontab -e
instead of creating a file at/etc/cron.d/certbot
. Adding a line to the crontab can work, but in that case you need to remove theroot
argument from the cron line. It's easier just to follow their instructions exactly.