Posts Tagged ssl

How to automate uploading SSL certificates from letsencrypt’s to DirectAdmin

On my shared hosting (where i have my personal website and my Polish blog) I had access to DirectAdmin panel and it have option to set SSL certificate, but it don’t have support for lensencrypt out of the box.

So I thought that I create python script that will upload Certificate for all of my domains that I can access from DirectAdmin and upload http challenges that are used by letsencrypt to confirm that I’m in control of the domain.

The script can be found on github gist

You need to update the cert.py script to include your username/password, ftp host and url for DirectAdmin interface, in my case I was using static url that was redirecting to different port and hosting provider domain, I’ve used that url because sometime the real server and domain change. That’s why the script use recursive function that send HEAD requests to get real url after redirect.

The gist include bash script, that can be used in cron (you need to put your domains and subdomains). If you will execute the script first time and was not using certbot before you will need to put your email and agree to TOS (using command line options).

The script cert.py is used in two modes one, if certbot environment variables are set, to upload a challenge to ftp and the other to set SSL certificate for each domain using DirectAdmin.

Instruction how to install certbot can be found on certbot.eff.org. After installation you can find short docs in man page for certbot that explain each command line option.

I’ve tested the script only on GNU/Linux. For Windows/MacOSX it will require modification like path to certificates generated by letsencrypt.

, , ,

Leave a comment

%d bloggers like this: