Page 1 of 1

Install Lets Encrypt on windows

Posted: Friday 29 July 2022 22:24
by foscolino
Hi,
Is there a guide to install Lets Encrypt on windows 10?
In the wiki I have find only linux installation :(
https://www.domoticz.com/wiki/Native_se ... ts_Encrypt

Re: Install Lets Encrypt on windows

Posted: Saturday 30 July 2022 21:36
by zicht
Hi

Haven't found a manual.
You can install certbot. (python implementation also for windows)
You can run certbot from lua .... But it has to be done with max permissions.
You can use tasksched for that :

Code: Select all

cmd=('schtasks /run /tn "Certbot"')
  os.execute(cmd)
Where Certbot is the tasksched task name

You will need to open port 80 for authentication purpose when the bot runs, thats just how it works. Makr sure during the process no other application is running on port 80. The certbot will start a small authenication server and the process will fail when the port is in use,
This can be done with windows firewall like this :

Code: Select all

 os.execute('netsh advfirewall firewall add rule name="DOMO" dir=in action=allow protocol=TCP localport=80')
and after remove it again

Code: Select all

 os.execute('netsh advfirewall firewall delete rule name="DOMO"')
if all worked as designed the certbot directory will contain a couple of new files that needs to be in the cert.
You can read that with io.open in lua.

Code: Select all

path="C:\\Certbot\\live\\site or domain name\\fullchain.pem"
   open = io.open
   file = open(path, "rb") 		-- r read mode and b binary mode
   spacer = file:read "*a" 		-- *a or *all reads the whole file
   file:close()
you may need to add some more data on the file like DH parameters ( static data) or priv key (new rolling data)
I am not an expert on that one.

Just read the right files, put the data in a string and write the cert file.

Code: Select all

path="C:\\Program Files (x86)\\Domoticz\\server_cert.pem"
   open = io.open
   file = open(path, "w+") 		
   file:write(result.."\n")		
   file:close()
i am not a coder, just a simple guy that reads and combines other peoples code. Thats how i created the above.
Hope it helps others.

Re: Install Lets Encrypt on windows

Posted: Monday 01 August 2022 11:07
by foscolino
Hi zicht, thank you very much!