You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
FR: Automatically configure Synology with tailscale cert in Settings : Security/Certificate #4674
I successfully secured my NAS by using Tailscale certs. The steps I've done:
Enable SSH on my Synology
SSH into the machine and run sudo tailscale cert my-domain
Copy the files somewhere I could download to my MacBook (that's needed unfortunately as Synology can't select a cert from its own disk)
Go to the Security/Certificate section and add a new certificate
After adding the certificate, make sure to click on Settings in the Security/Certificate tab to use the new certificate:
The final result on the Security/Certificate tab should look like:
After these steps, I could visit my Synology home page and could verify that HTTPS work out of the box:
How should we solve this?
It would be dope if the Synology Tailscale application could automatically generate and add the certificate to the settings. After that, the users could go to the Security/Certificate tab and enable the certificate for the services they are interested in.
What is the impact of not solving this?
It's cumbersome to set up HTTPS for Synology NAS, see the above steps.
Anything else?
No response
Reacted by Christophe Tafani-Dereeper, David Anthoff, George Witteman, Geoffrey Gallaway, Chris Knowles, AntoineChn, Antsiscool, TJ Maynes, Kurt Raschke, benjamin-hg and 33 more
changed the title [-]FR: Automatically configure Synology with `tailscale cert` output[/-][+]FR: Automatically configure Synology with `tailscale cert` in Settings : Security/Certificate[/+]on Aug 28, 2022
You only need to replace xxxx.xxxx.ts.net by your own domain. The IUou7F folder might be different for everyone as well. If your tailscale certificate is configured as default, you can check the folder running sudo cat /usr/syno/etc/certificate/_archive/DEFAULT
Reacted by Alex Sherwin, grandmastermarco, Ihor Vovk, Hopkins and Shengyu Zhang
Reacted by NolanT, Sierra Thacker, Cesare Tagliaferri, Justin Bonnar, benjamin-hg, beekmen, Jeremy Stucki, Keitaroh Kobayashi, Johan M., Almad and 3 more
I ended here looking for a way to automatically replace the tailscale certificate on Synology. Thank you so much @maxenceleduc92 for your script! I run a slight variation of it as a daily task. I had only one problem with it: for some reason, restarting nginx on Synology triggers a chain reaction of restarts (my problem was with docker restarting, while my containers might be doing something important).
To the best of my knowledge, reloading nginx is sufficient to switch to the new certificate, so I have replaced the last line with: /usr/syno/bin/synosystemctl reload nginx. This does not trigger a restart for Docker, Web Station, etc.
Reacted by Maxence Leduc, hgain, WinstonSmith73 and Shengyu Zhang
You may also want to send an email in case the script fails (there's a checkbox for it)
BTW I used the reload nginx variant of @taglia and altough my DSM listed the updated certificate, my browser did not want to show it unless I restarted my box. As I'm running the script on a daily basis and also restarting my NAS every day, this is not an issue with a 3 months certicate lifetime.
Only thing I would suggest also doing at the end of the script is to delete the xxxx.xxxx.ts.net.crt, xxxx.xxxx.ts.net.key and p8file.pem files from the default directory that they get created in. It's probably pretty low risk but better to clean up to be sure. Here's a slight revision to the earlier script that'll do that for you.
BTW has anyone figured out how to use tailscale certs with DSM 6? I get an error when adding the cert initially via the DSM 6 UI saying "DSM does not support ECC certificates" and I can't figure out a workaround. Is this really only possible in DSM 7?
Reacted by beekmen, Rene Greuel, Alysson Souza e Silva, Maxence Leduc, Pierre Baillet, Sebastian Osiński, Keitaroh Kobayashi, Mario Drengner, Bradley Wilson-Hunt, Adam Lowry and 12 more
FYI Hyper Backup on DSM 7.2 fails to accept a Tailscale certificate (you get a highly uninformative and incorrect "network is not working" error message from the backup source; a packet capture on the Vault (destination) NAS shows it doing a TCP RST after a short exchange). Switching the Vault TLS certificate to use the Synology 'QuickConnect' TLS cert gets it going again. The Tailscale cert continues to function just fine for HTTP access (i.e. System Default).
I have found a CLI tool which can be used to invoke the Synology web API as an admin without credentials (it does have to be run as root though). I suspect that will be more future-proof than copying files around in the internal directories. My PR #10994 packages this all up into one tailscale CLI command for convenience, but as a workaround in the meantime, here's an adaptation of the script from @tux86 that uses the synowebapi command.
#!/bin/bash# Exit if not running as rootif [ "$EUID"-ne 0 ];thenecho"This script must be run with sudo."exit 1
fi
USER_HOME=$(eval echo~$SUDO_USER)
TEMPDIR="$USER_HOME/.tailscale_certs"
TS_DNS=$(tailscale status --json | jq -r '.Self.DNSName | .[:-1]')
SYNO_ID=$(cat /usr/syno/etc/certificate/_archive/DEFAULT)# We will overwrite the default certificate# Prepare temporary cert directory
rm -f "$TEMPDIR/$TS_DNS*.pem"
mkdir -p "$TEMPDIR"# Generate Tailscale certificates
tailscale cert --cert-file "$TEMPDIR/$TS_DNS.crt.pem" --key-file "$TEMPDIR/$TS_DNS.key.pem""$TS_DNS"# Import the certificates via the Synology web API.
/usr/syno/bin/synowebapi --exec api="SYNO.Core.Certificate" method=import version=1 \
id="\"$SYNO_ID\"" desc="\"Tailnet Certificate\"" \
cert_tmp="\"$TEMPDIR/$TS_DNS.crt.pem\"" \
key_tmp="\"$TEMPDIR/$TS_DNS.key.pem\""# Restart the Synology web server
/usr/syno/bin/synosystemctl restart nginx
# Clean up temporary directory
rm -rf "$TEMPDIR"
Wouldn't it suffice to reload nginx rather than restarting it? Also, I feel like synowebapi might be able to take care of activating the new certificate, including restarting/reloading services. It returns a JSON suggesting that it could at least restart httpd:
I have found a CLI tool which can be used to invoke the Synology web API as an admin without credentials (it does have to be run as root though). I suspect that will be more future-proof than copying files around in the internal directories. My PR #10994 packages this all up into one tailscale CLI command for convenience, but as a workaround in the meantime, here's an adaptation of the script from @tux86 that uses the synowebapi command.
#!/bin/bash# Exit if not running as rootif [ "$EUID"-ne 0 ];thenecho"This script must be run with sudo."exit 1
fi
USER_HOME=$(eval echo~$SUDO_USER)
TEMPDIR="$USER_HOME/.tailscale_certs"
TS_DNS=$(tailscale status --json | jq -r '.Self.DNSName | .[:-1]')
SYNO_ID=$(cat /usr/syno/etc/certificate/_archive/DEFAULT)# We will overwrite the default certificate# Prepare temporary cert directory
rm -f "$TEMPDIR/$TS_DNS*.pem"
mkdir -p "$TEMPDIR"# Generate Tailscale certificates
tailscale cert --cert-file "$TEMPDIR/$TS_DNS.crt.pem" --key-file "$TEMPDIR/$TS_DNS.key.pem""$TS_DNS"# Import the certificates via the Synology web API.
/usr/syno/bin/synowebapi --exec api="SYNO.Core.Certificate" method=import version=1 \
id="\"$SYNO_ID\"" desc="\"Tailnet Certificate\"" \
cert_tmp="\"$TEMPDIR/$TS_DNS.crt.pem\"" \
key_tmp="\"$TEMPDIR/$TS_DNS.key.pem\""# Restart the Synology web server
/usr/syno/bin/synosystemctl restart nginx
# Clean up temporary directory
rm -rf "$TEMPDIR"
Wouldn't it suffice to reload nginx rather than restarting it? Also, I feel like synowebapi might be able to take care of activating the new certificate, including restarting/reloading services. It returns a JSON suggesting that it could at least restart httpd:
The value of restart_httpd depends on some factors unknown to me, but you don't need to specify anything, DSM will just auto-detect it. I've also been able to confirm that you don't need to restart anything manually, at least not for my use case. I've first replaced the certificate with a bogus one in the web GUI, which gave me a certificate error in my browser after refreshing the page, and then I ran the script to generate and import the correct certificate again without touching nginx, and it worked immediately. It returned this:
Isn't it gonna take a while for the Tailscale synology package to be updated to support this magic command though?
My Synology package manager said my 1.58.2 install was "up to date", but SSH'ing into my Synology and running sudo tailscale update upgraded it to 1.70.0, which was enough to make the rest of the instructions work.
Activity
durind commentedon Aug 9, 2022
Hi,
This could be done with the feature I requested in #5011 and for example with a script like https://github.com/looran/synoadm/blob/main/synoadm.sh
[-]FR: Automatically configure Synology with `tailscale cert` output[/-][+]FR: Automatically configure Synology with `tailscale cert` in Settings : Security/Certificate[/+]maxenceleduc92 commentedon Oct 17, 2022
Hi,
I think I got something that sucessfully updates tailscale certificates on Synology.
You only need to replace xxxx.xxxx.ts.net by your own domain. The IUou7F folder might be different for everyone as well. If your tailscale certificate is configured as default, you can check the folder running
sudo cat /usr/syno/etc/certificate/_archive/DEFAULTtaglia commentedon Dec 4, 2022
Hi,
I ended here looking for a way to automatically replace the tailscale certificate on Synology. Thank you so much @maxenceleduc92 for your script! I run a slight variation of it as a daily task. I had only one problem with it: for some reason, restarting nginx on Synology triggers a chain reaction of restarts (my problem was with docker restarting, while my containers might be doing something important).
To the best of my knowledge, reloading nginx is sufficient to switch to the new certificate, so I have replaced the last line with:
/usr/syno/bin/synosystemctl reload nginx. This does not trigger a restart for Docker, Web Station, etc.benjamin-hg commentedon Dec 29, 2022
Thanks a lot, @maxenceleduc92!
To safe people like me some time figuring out how to schedule this script:
Use the Task Scheduler of DMS (https://kb.synology.com/en-global/DSM/help/DSM/AdminCenter/system_taskscheduler?version=7), choose "user-defined script" and user "root" (admin won't work!)
You may also want to send an email in case the script fails (there's a checkbox for it)
BTW I used the
reload nginxvariant of @taglia and altough my DSM listed the updated certificate, my browser did not want to show it unless I restarted my box. As I'm running the script on a daily basis and also restarting my NAS every day, this is not an issue with a 3 months certicate lifetime.pjdubya commentedon Jan 1, 2023
@maxenceleduc92 you are amazing. Thank you so much!
Only thing I would suggest also doing at the end of the script is to delete the xxxx.xxxx.ts.net.crt, xxxx.xxxx.ts.net.key and p8file.pem files from the default directory that they get created in. It's probably pretty low risk but better to clean up to be sure. Here's a slight revision to the earlier script that'll do that for you.
BTW has anyone figured out how to use tailscale certs with DSM 6? I get an error when adding the cert initially via the DSM 6 UI saying "DSM does not support ECC certificates" and I can't figure out a workaround. Is this really only possible in DSM 7?
rderewianko commentedon Jan 3, 2023
I've edited the script above a bit (also because i'll end up using the ssl certificate within docker)
af3556 commentedon Jul 1, 2023
FYI Hyper Backup on DSM 7.2 fails to accept a Tailscale certificate (you get a highly uninformative and incorrect "network is not working" error message from the backup source; a packet capture on the Vault (destination) NAS shows it doing a TCP RST after a short exchange). Switching the Vault TLS certificate to use the Synology 'QuickConnect' TLS cert gets it going again. The Tailscale cert continues to function just fine for HTTP access (i.e. System Default).
i.e. this seems to work:

14 remaining items
martijk commentedon Mar 8, 2024
This is really great, thanks for sharing!
Wouldn't it suffice to reload nginx rather than restarting it? Also, I feel like
synowebapimight be able to take care of activating the new certificate, including restarting/reloading services. It returns a JSON suggesting that it could at least restart httpd:{ "data" : { "id" : "t7UVwb", "restart_httpd" : false }, "httpd_restart" : false, "success" : true }I'll see if I can verify that.
martijk commentedon Mar 8, 2024
The value of
restart_httpddepends on some factors unknown to me, but you don't need to specify anything, DSM will just auto-detect it. I've also been able to confirm that you don't need to restart anything manually, at least not for my use case. I've first replaced the certificate with a bogus one in the web GUI, which gave me a certificate error in my browser after refreshing the page, and then I ran the script to generate and import the correct certificate again without touching nginx, and it worked immediately. It returned this:{ "data" : { "id" : "oFvj7Y", "restart_httpd" : true }, "httpd_restart" : true, "success" : true }Note that the ID is different from the one in my previous comment, but that's because I used another device to test this.
I use this modified version of the script to run a weekly task as root with the task scheduler:
cmd/tailscale/cli: Add CLI command to update certs on Synology devices.
alexraskin commentedon Jun 19, 2024
for anyone wanting to setup an automated check, I wrote this cert check script... https://github.com/alexraskin/tailscale-cert-renewal-synology/blob/main/tailscale_cert_script.sh
cmd/tailscale/cli: Add CLI command to update certs on Synology devices.
sim642 commentedon Aug 11, 2024
Since it may not be entirely obvious to everyone, PR #10994 implemented an official command to do this, so custom scripts are no longer necessary.
However, for some reason the new command is nowhere documented (except for the PR), so I wrote my own guide here: https://sim642.eu/blog/2024/08/11/tailscale-https-certificate-on-synology-nas/. Hopefully, it also gets mentioned in the official Tailscale documentation at some point.
jdumas commentedon Aug 11, 2024
Isn't it gonna take a while for the Tailscale synology package to be updated to support this magic command though?
tux86 commentedon Aug 11, 2024
it works ! thank you for sharing.
I have tailscale v 1.70 installed on my Synology:

Command documentation (cli help) :

As detailed in @sim642 article, here are the instructions for automating certificate renewal.
Step 1:
Step 2:
Step 3:
Step 4:
flammable commentedon Aug 11, 2024
Confirming this works great on 1.70.0. Thanks for writing up the instructions!
kurrik commentedon Aug 11, 2024
My Synology package manager said my 1.58.2 install was "up to date", but SSH'ing into my Synology and running
sudo tailscale updateupgraded it to 1.70.0, which was enough to make the rest of the instructions work.xiNeRoar commentedon Aug 23, 2024
Will this apply https to the short domain as well? Or it only apply to the fqdn?
sim642 commentedon Aug 23, 2024
The general Tailscale HTTPS documentation answers this:
cmd/tailscale/cli: Add CLI command to update certs on Synology devices.
mback2k commentedon Aug 28, 2024
There is currently also an issue with the certificate generated, please see: #12762