SSL certificate in Hass.io & Home Assistant Core on Synology -

Опубликовано: 09 Октябрь 2024
на канале: BeardedTinker
17,235
127

If you got your Let's Encrypt certificate ready on Synology, it's time to install it in Home Assistant, and I'll show you how to for both Hass.io Home Assistant and Home Assistant Core.

00:00 Intro

Steps for Hass.io are done according to this guide:
https://www.jens-bretschneider.de/has...
Thanks andilge for pointing me to this one!

Check previous video if you haven't created DuckDNS URL and Let's Encrypt certificate:    • DuckDNS and Let's Encrypt for Home As...  

00:57 - First step is to locate certificate. For that we open terminal application and go to folder:

/usr/syno/etc/certificate/system/default

Use "ls -l" to list contents of the folder and see if you have privkey.pem and fullchain.pem files there.

02:15 - Using Synology - Control Panel - Task Scheduler, create new task. Give it a name and go to Task settings, where you have to copy following script:

SRC="/usr/syno/etc/certificate/system/default"
DEST="/volume1/docker/hass.io/ssl"
if [ ! -f "$DEST/fullchain.pem" ] || [ "$SRC/fullchain.pem" -nt "$DEST/fullchain.pem" ]; then
cp "$SRC/fullchain.pem" "$DEST/"
cp "$SRC/privkey.pem" "$DEST/"
chown root:root "$DEST/fullchain.pem" "$DEST/privkey.pem"
chmod 600 "$DEST/fullchain.pem" "$DEST/privkey.pem"
/usr/syno/bin/synowebapi --exec api=SYNO.Docker.Container version=1 method=restart name=homeassistant
fi

Please verify that first two folders are according to your setup. By default they should be like this.

05:58 - in your Home Assistant add following to your configuration.yaml file:

http:
ssl_certificate: /ssl/fullchain.pem
ssl_key: /ssl/privkey.pem

You can now run script so it can copy certificates for the first time.

09:11 - If you have problem and your system seems to be running on Synology Inc. certificate, check if you have other certificates by looking in terminal to this folder:

/usr/syno/etc/certificate/_archive

If you cant access folder, first use command "sudo -i" to elevate your access rights.

13:07 - for Home Assistant, steps are same, there is just difference on where you need to copy certificate and in in path in configuration.yaml file:

13:11 - Verify also if your SSL certificates are in /usr/syno/etc/certificate/system/default or some other sufolder in /usr/syno/etc/certificate/_archive AND check Docker container name in script as it should match Docker container name in Synology.

13: 35 - Scripts also goes to Control Panel - Task Scheduler:

SRC="/usr/syno/etc/certificate/system/default"
DEST="/volume1/docker/home-assistant"
if [ ! -f "$DEST/fullchain.pem" ] || [ "$SRC/fullchain.pem" -nt "$DEST/fullchain.pem" ]; then
cp "$SRC/fullchain.pem" "$DEST/"
cp "$SRC/privkey.pem" "$DEST/"
chown root:root "$DEST/fullchain.pem" "$DEST/privkey.pem"
chmod 600 "$DEST/fullchain.pem" "$DEST/privkey.pem"
/usr/syno/bin/synowebapi --exec api=SYNO.Docker.Container version=1 method=restart name=home-assistant
fi

16:28 - In configuration.yaml file in Home Assistant, add following lines:

http:
ssl_certificate: /config/fullchain.pem
ssl_key: /config/privkey.pem

After your created Task and edited your configuration.yaml file, you can run Task in Task Scheduler for the first time to copy certificate and restart Home Assistant.

This should be it. Your Hass.io/Home Assistant should now be available on https;//ip_adddress:8123.

Thank you for watching this video. If you have any questions or comments , please leave them below or contact me on the Discord Server.

Be safe and have fun!
BeardedTinker

Twitter: @BeardedTinker
Discord:   / discord  

#HomeAssistant #hassio #Letsencrypt #Synology