I wrote a quick tutorial on how to set up Let’s Encrypt and DuckDNS without needing to expose Port 80 to the outside world using the “dehydrated” script instead of the heavy weight certbot tool.
The advantage of using DNS challenges is that I do not need to worry about what runs on port 80 (in my case it’s emulated_hue for Google Home) when doing the certificate renewal.
This works for me up until I get to generating the certificates. The script gets to the “Requesting challenge for mydomain.duckdns,org”, then exits with the message “curl: (60) SSL certificate problem: self signed certificate in certificate chain”. The error is coming when the "curl “https://www,duckdns,org/update?domains=$domain&token=$token&txt=$4"” command is run in the hook,sh file, but I’m not sure why this is, and can’t find another instance of this online.
Hmm sounds very weird indeed. The certificate at duckdns seems to be perfectly fine to me. No idea what’s going wrong there for you. Maybe some proxy in between?
I’m only seeing this topic now and I love this approach @splitbrain ! Would you want to work with me to see if we can get this added to Home Assistant as two new components: one for DuckDNS and one for Let’s Encrypt ?
My vision would be that a configuration could look something like this:
# Open the port on the router to allow accessing it remotely (already exists)
upnp:
# Will keep IP up to date and allow setting TXT record
duckdns:
domain: bla.duckdns.org
token: ABCDEFGH
# Will check cert status on startup and every X days,
# if not exist or about to expire will set TXT record and do verification.
# Future: auto-configures certs in HTTP component ?!
letsencrypt:
platform: duckdns
I like the idea of a ‘letsencrypt’ component that can support multiple DDNS providers – I, for instance, am using http://freedns.afraid.org and would love to accomplish a similar setup (hass.io-centered or not).
dehydrated uses a custom hook file to interface with whatever DNS provider you’re working with. Check their wiki for examples. Shouldn’t be to hard to support afraid.org if they have an API.
I too am wondering if this is only for hass.io? I’m new to home assistant and still trying to figure things out but I don’t see how or where to install the duckdns addon?
@splitbrain, thanks for putting this together. I got this setup last night and its nice to finally have an https: connection for my HA instance.
Would you mind if I created a guide for less experienced users on how to implement your setup? I will give you all the credit for development and link to your site. I think your guide is good, however, I think a step by step option may lower the bar for less experienced users.
I found I had to add my home assistant user as a sudo user temporarily for example, that is an error that a number of people would run into and likely get stuck at. Even something as simple as changing the current directory can throw a hurdle for basic users.
sure go ahead, I realize that my description needs some familiarity with Unix/Linux systems to fill in the blanks. A more beginner friendly guide is probably welcome.
I think I ran into one of the issues. When following the guide from splitbrain I have successfully created the the let’sencrypt certificates, but get an error message from Homeassistant saying the files do not exist (they do).
In the tutorial they mention that the key files are located in
If you are on hassbian, did you switch users and enter the virtual environment first? This is where I got tripped up. I am not sure that the homeassistant user (what HA runs commands as) can access the files if they are not within the home assistant virtual environment.