Synology DSM 7 with Let's Encrypt and DNS Challenge Using Vultr DNS
This guide walks you through setting up a Let's Encrypt SSL certificate on a Synology NAS running DSM 7 using the DNS challenge method with Vultr DNS. It includes automating renewals correctly using the acme.sh
script.
Why Use the DNS Challenge?
Synology provides a built-in way to obtain SSL certificates, but it requires:
- Ports 80 and 443 to be open to the public internet, or
- Using Synology’s DDNS service.
If you want to use your custom domain and avoid exposing your NAS to the internet, the DNS challenge is an excellent alternative. It works by adding a DNS TXT record to prove domain ownership.
Prerequisites
- A Synology NAS running DSM 7 with SSH enabled.
- A domain name managed by Vultr DNS.
- A Vultr API key to automate DNS record updates.
- The
acme.sh
script for issuing and managing certificates.
Step 1: Create a Synology User for Certificate Management
- Log into Synology DSM and go to Control Panel > User & Group > Create.
- Create a new user (e.g.,
certadmin
). - Add the user to the administrators and http groups.
- Grant Read/Write access to the
homes
folder. - Deny access to all applications.
- Create a new user (e.g.,
- Enable SSH Access:
- Go to Control Panel > Terminal & SNMP > Terminal.
- Check Enable SSH service and apply the changes.
Step 2: Access the NAS via SSH
- Open a terminal (on macOS/Linux) or PuTTY (on Windows).
- Enter the password for the
certadmin
user.
Connect to your NAS using SSH:
ssh certadmin@<NAS_IP_ADDRESS>
Replace <NAS_IP_ADDRESS>
with your NAS's IP address or hostname.
Step 3: Install acme.sh
Download and install the acme.sh
script:
wget -O /tmp/acme.sh.zip https://github.com/acmesh-official/acme.sh/archive/master.zip
sudo 7z x -o/usr/local/share /tmp/acme.sh.zip
sudo mv /usr/local/share/acme.sh-master/ /usr/local/share/acme.sh
sudo chown -R certadmin /usr/local/share/acme.sh/
cd /usr/local/share/acme.sh
Step 4: Configure Environment Variables
Set the necessary variables for Vultr DNS and Synology:
export VULTR_API_KEY="YOUR_VULTR_API_KEY"
export SYNO_Username="certadmin"
export SYNO_Password="YOUR_CERTADMIN_PASSWORD"
export SYNO_Certificate="Let's Encrypt"
export SYNO_Create=1
- Replace
YOUR_VULTR_API_KEY
with your Vultr API key. - Replace
YOUR_CERTADMIN_PASSWORD
with the password for thecertadmin
user.
Step 5: Issue a Let's Encrypt Certificate
Run the following command to issue a certificate for your domain:
./acme.sh --server letsencrypt --issue --dns dns_vultr -d "example.yourdomain.com" --home $PWD
- Replace
example.yourdomain.com
with your actual domain. - This command:
- Uses the Vultr DNS API to create a DNS TXT record.
- Validates domain ownership.
- Issues and saves the certificate on the NAS.
Step 6: Deploy the Certificate
Deploy the certificate to the Synology DSM:
./acme.sh -d "example.yourdomain.com" --deploy --deploy-hook synology_dsm --home $PWD
- This command:
- Logs into the Synology DSM interface.
- Uploads the certificate.
- Applies it to the web interface and restarts necessary services.
Step 7: Automate Certificate Renewal
- Open Control Panel > Task Scheduler on your Synology NAS.
- Click Create and select Scheduled Task > User-defined Script.
- Configure the task:
- General Tab:
- Name:
Renew Let's Encrypt Certificate
- User:
certadmin
- Name:
- Schedule Tab:
- Set the task to run daily.
- Task Settings Tab:
- General Tab:
- Save and enable the task.
Add the following script:
/usr/local/share/acme.sh/acme.sh --cron --home /usr/local/share/acme.sh
Step 8: Verify the SSL Certificate
- Log into the DSM web interface via HTTPS.
- Go to Control Panel > Security > Certificate to confirm the new certificate is active.
- Optional: Enable HTTP to HTTPS redirection under Control Panel > Login Portal > DSM Settings.
Notes
- Let’s Encrypt certificates are valid for 90 days. The
--cron
task ensures they are renewed automatically. - If 2FA is enabled for the
certadmin
account, follow the instructions on TOTP setup. - Always disable SSH access after configuration for better security.
Summary
This guide shows how to set up a Let's Encrypt SSL certificate for a Synology NAS using Vultr DNS. The DNS challenge avoids the need to expose ports or use Synology's DDNS, giving you more control and security. By automating renewals, your NAS will always have a valid certificate without manual intervention.
Enjoy your secure Synology NAS!