A while ago I wrote an article that described all the steps necessary to obtain a free SSL certificate with a validity of 90 days. Check it out: https://www.ajni.it/2019/06/claiming-a-free-ssl-certificate-for-your-website/
While it’s good to know how things work, the task gets boring and repetitive if you have to do it every 3 months and in my case for two different domains. This is why I wrote a small and straightforward script in Python3 that does that all for me.
ZeroSSL offers an API that allows us to automate this task by making some HTTP calls with an API key obtainable after registering.
I have uploaded the script on GitHub, check it out:
https://github.com/ajnik/ZeroSSL-CertRenew
There are some variables that must be changed:
- Line 19: API key
- Line 20: Domain name
- Line 43 to 52: Request paramteres (O, OU, L, ST, C)
Execute the script with
python3 ZeroSSL_CertRenew.py
The script does no exception handling. I might improve it in the future.
Let me know if you have any suggestions. I am pretty new to Python programming so every tip is welcome.
I just installed a ZeroSSL certificate on my Godaddy website via cpanel, and would like to be able to automate it. I have no experience with Python or how to install your script.
Are you still working on it?
Well, it’s been a long time, but it should work. Do you have shell access through SSH to your server? If you do, you can execute the script with python3 script.py (also check the GitHub link).
I have problems with the following
root@lamp:~/scripts/certificado_ssl/ZeroSSL-CertRenew-master# python ZeroSSL_CertRenew.py
File “ZeroSSL_CertRenew.py”, line 49
subjectAltName = ‘DNS: www.{self.certificateDomain}, DNS: {self.certificateDomain}”’
^
SyntaxError: invalid syntax
root@lamp:~/scripts/certificado_ssl/ZeroSSL-CertRenew-master#
Are you using python3?
Python version = Python 3.5.2
File “renew.py”, line 51
subjectAltName = DNS: www.{self.certificateDomain}, DNS: {self.certificateDomain}”’
^
I am using python 3.8.5 and that part works just fine. It seems like there is a line break right after DNS:
What happens if you try to execute these lines in an interactive python shell?
certificateDomain = ‘domain.com’
Lines 32 through 51 – replace self.certificateDomain with certificateDomain.