Auto https cert renewal on Synology DS418

I recently set up my automatic https cert renewal from Let’s Encrypt on my Synology DS418 running DSM 7.4 software, keeping keeping my own home.netjeff.com name. The built-in support in the DSM admin GUI required either using a synology.me name, or opening port 80. But using acme.sh I’ve been able to set up auto renewal with my own home.netjeff.com and without opening port 80.

If you’re running Synology with cPanel-based DNS, feel free to skip the next Background session, and go directly to the details.

Background

I run a Synology DS418 with DSM 7.4 software at home.netjeff.com. I only expose secure https for home.netjeff.com, which requires a certificate. In theory I could use a self-signed certificate, but browsers give scary warnings when self-signed, and some apps on will refuse to work with self-signed. So I want a “real” certificate.

Until recently I was purchasing a certificate from a well-known authority, and then manually installing into my Synology. When I started buying these certs several years ago, I could get a certificate that would last for 5 years. Then it dropped to 2 years. Recently it’s dropped to 200 days. I can’t deal with the hassle of updating a certificate every 200 days. And it’s only going to get worse – next year it drops to 100 days, and then to 47 days beginning 2029.

Synology’s built-in DSM admin GUI supports automatic certificate renewal with Lets Encrypt. If you run your Synology using Synology’s in-house DDNS, for example my-ds418.synology.me, it’s very seamless to set up automatic renewals for certs. Use the DSM admin GUI, and it all “just works”. If you’re using a synology.me name, you can stop reading now, just use the built-in support in DSM gui. :-)

But I want to keep using my own home.netjeff.com name, not a *.synology.me name. Unfortunately, keeping my own name with the DSM admin GUI would require me to open port 80 to the Internet, which I don’t recommend.

I found acme.sh, a flexible command-line tool that that runs on most linux systems. The acme.sh tool follows the ACME standard (RFC 8555), used across the Internet. acme.sh supports DNS-01 mode so no need to open port 80. acme.sh has lots of integrations, including integrations for DSM and cPanel DNS.

acme.sh provides extensive documentation. But only a tiny portion of those docs apply to my combination of Synology and cPanel for DNS. The acme.sh wiki has a dedicated Synology page which is more focused on my specifics. But even that page is not a perfect match because t uses an example with CloudFlare DNS rather than cPanel. Plus there’s some details that I think could be better.

I’ve written this page to both remind myself in the future about how I got this working with DSM and cPanel-based DNS, and also in case it helps others with same combination.

Overview of using acme.sh

Here’s an overview of using acme.sh

  1. Install acme.sh on a Synology device
  2. Configure acme.sh for DNS with my cPanel-based DNS
  3. Create a new certificate using Lets Encrypt
  4. Deploy the new cert into the DSM software
  5. Use the new certificate
  6. Configure automatic renewal.
  7. Update acme.sh when new versions released.

1. Install acme.sh

SSH into your Synology box using your admin account. You may need to enable SSH in the DSM gui on your Synology box.

Run these commands once you’ve ssh’d into your Synology:

sudo -i

umask 077

wget -O /tmp/get.acme.sh https://get.acme.sh

less /tmp/get.acme.sh  # (optional) confirm script not malicious

sh /tmp/get.acme.sh \
email=your.email@example.com \
--home /usr/local/share/acme.sh \
--nocron

Change the email address to match your own. Lets Encrypt will use this email to send reminders.

See also the official “How to install” page on the acme.sh wiki for more details.

2. Configure for DNS

For my netjeff.com domain, I use the cPanel-based DNS provided by my hosting provider. This step configures acme.sh to also use cPanel as part of certificate creation (in later steps).

Note: If you’re using a different DNS system, see the wide variety of alternatives on the official “How to use DNS API” section on the acme.sh wiki.

Continuing in the same ssh session, set these env vars to tell acme.sh the cPanel user and host:

export cPanel_Username='YOUR_CPANEL_USERNAME'
export cPanel_Hostname='https://cpanel.netjeff.com'

Change the example above for the username you use with your cPanel, and the host for your cPanel. Some cPanel installations will require you to include a port number, like 'https://example.com:2083'

Next, use your cPanel gui to get an “api token“. Exact details on how to get an api token depend on the version of cPanel you’re using.

Treat this token like a special-purpose password. Anyone with this token can change your DNS.

Copy the api token to your clipboard, and then run this command, all as a single line:

printf 'Paste API token: '; read -r cPanel_Apitoken

Paste from your clipboard. Tap [Enter] key after paste.

Finally, run one more command to finish this step.

export cPanel_Apitoken

Now your ssh session has the following env vars set

  • cPanel_Username
  • cPanel_Apitoken
  • cPanel_Hostname

Later steps will use these env vars, so you can now continue.

These steps are based on the official “Use cPanel DNS systems” section on the acme.sh wiki.

If you’re using a different DNS system, see the wide variety of alternatives on the official “How to use DNS API” section on the acme.sh wiki.

3. Create a certificate with Lets Encrypt

In this step you’ll use acme.sh to interact with Lets Encrypt to create a certificate. This is also called “issuing” a certificate.

Continuing in the same ssh session, run this command:

/usr/local/share/acme.sh/acme.sh --issue /
--home /usr/local/share/acme.sh /
--server letsencrypt /
--dns dns_cpanel
-d home.netjeff.com

Change the last line to match the name you use to reach your Synology (example above uses my home.netjeff.com).

This command tells acme.sh to work with Lets Encrypt using DNS-01 mode, to get a certificate created by Lets Encrypt for your Synology, also telling acme.sh to use your cPanel-based DNS gui.

You’ll see lots of output. If there are any problems, there will be obvious error messages in the output. If errors, the most likely are mistakes when setting the $cPanel_* env vars in the previous steps. Try fixing the env vars, and re-run the command.

When no errors, continue to the next step.

4. Deploy the new certificate into DSM

The DSM software on your Synology does not yet know about this newly created certificate. You need to “deploy” the certificate into DSM.

First set these env vars to tell acme.sh to work with DSM

export SYNO_USE_TEMP_ADMIN=1
export SYNO_CREATE=1
export SYNO_CERTIFICATE='home.netjeff.com via acme.sh'

Change the SYNO_CERTIFICATE value for your dns. This is the friendly name shown in your Synology’s DSM admin gui.

Now run this command to deploy the certificate into DSM:

/usr/local/share/acme.sh/acme.sh --deploy  \
--home /usr/local/share/acme.sh \
--deploy-hook synology_dsm \
-d home.netjeff.com

Change the last line to match the name you use to reach your Synology (example above uses my home.netjeff.com).

If there are any problems, there will be obvious error messages in the output. If no errors you can continue to the next step

These steps are based on the “Deploy the certificate to Synology DSM” section on the acme.sh wiki.

5. Use the new certificate

Your Synology’s DSM software knows about the new certificate, but hasn’t started to actually use it. In these steps you’ll use the DSM Control Panel in your Synology. The steps below are based on currently latest DSM 7.4.

In the DSM admin gui, open Control Panel > Security > Certificate. See also the official Synology docs.

If you see multiple entries, each entry has a description. Look for the entry with the description that includes the text from SYNO_CERTIFICATE you entered in the previous step.

Click the “Settings” button. A new window will appear that lists all the services running on your Synology. For each service, change the certificate to use this new certificate. Click “Ok”.

Back at the list of certs, single-click this new cert to highlight. If the cert does not show as “default”, click the button Action > Edit, and set as default.

Now the Synology is actually using the new certificate.

6. Configure for automatic renewal

New certificates include an expiration date. After the expiration date most browsers and apps will give warnings. So you need to update the cert before the certificate expires. This step sets up automatic renewal using acme.sh. You don’t want to have to remember to come into the DSM admin gui to renew. Beginning March 2027 certs will expire in 100 days, and beginning 2029 they will expire at 47 days.

In this step you’ll use DSM to schedule a daily task. You’ll create a task that runs acme.sh every day, to both check if renewal needed, and then automatically renew before expiration.

In DSM admin GUI, go to Control Panel > Task Scheduler. See also the official Synology docs.

Then use Create > Scheduled Task> User Defined Script. Set user to ‘root’. Give the task a name like ‘Cert check and renew with acme.sh’. I set a once-a-day schedule. Use the following for the command in Task Settings

/usr/local/share/acme.sh/acme.sh --cron --home /usr/local/share/acme.sh

Enable the option for “send email on failure”. Confirm that you’ve previously configured DSM to be email capable, in Control Panel > Notification > Email. If not configured yet , look for guides elsewhere on how to setup your Synology DSM for email in general.

To confirm that this new task is configured properly, run the task now from the DSM gui, and use “View Results” to check the output. It should show no errors, and message that it’s “skipping” because renewal date in the future.

7. Update acme.sh when new versions

As of 2026 there are a few releases of acme.sh every year. You don’t want to let your acme.sh get too far behind.

acme.sh supports an --upgrade option. When run this way, acme.sh checks for updates, and then updates when available.

You could create another Task in DSM that automatically runs periodically. But I’m a little too nervous to let the update happen automatically.

So I’ve created a Task without an automatic schedule, which I can run manually. You can follow the previous steps for automatic renewal, but leave the schedule empty. Then set this as the command:

/usr/local/share/acme.sh/acme.sh --upgrade  \
--home /usr/local/share/acme.sh \
--auto-upgrade 0 && \
/usr/local/share/acme.sh/acme.sh --version \

When acme.sh creates a new release, I login into the DSM admin GUI, and then manually run this task.

To keep track of new acme.sh releases, I have an account on GitHub, and then on the acme.sh GitHub page, I’ve requested notifications when new releases.


Advanced topics (optional)

This section includes some advanced topics. These are strictly optional, no need to read unless you’re really interested.

Date of cert renewal

If you’re curious to see when acme.sh will actually renew the cert, run this command in ssh while root, and then look for Le_NextRenewTimeStr in the output

/usr/local/share/acme.sh/acme.sh --info  \
--home /usr/local/share/acme.sh \
-d home.netjeff.com

Why the ‘printf’ to set cPanel_Apitoken env var?

In step 2 “Configure DNS” above, you set the env var cPanel_Apitoken like this

printf 'Paste API token: '; read -r cPanel_Apitoken

[paste from clipboard]

export cPanel_Apitoken

Elsewhere you might see instructions that show running a simpler single command like this:

export cPanel_Apitoken '[paste from clipboard]'

The risk of this simpler command is that bash might save the api token into the shell history. This api token is similar to a password, so you really want to limit it getting saved. The slightly more complicated steps using printf guarantees the value is not stored in bash command history

Simpler one-line install

Elsewhere you may might see instructions for install that are slightly simpler, that look like this:

sudo -i

umask 077

wget -O - https://get.acme.sh | sh

The wget above downloads the installer and runs immediately. My instructions above split up the download from the run, so that you can double-check nothing suspicious.

Regarding using ‘root’ for acme.sh

My instructions above mean that acme.sh runs as root, because of the sudo command back in step 1.

In theory it’s a good idea to minimize the amount of software that runs as root, because software running as root can accidentally (or maliciously) mess up your Synology.

But in this case, to avoid running as root you’d replace this

export SYNO_USE_TEMP_ADMIN=1

with

export SYNO_USERNAME='Admin_Username'
export SYNO_PASSWORD='Admin_Password!123'

The problem with this is that now your admin Synology password is more “exposed” to potentially other malicious software that has infected our Synology.

I’ve decided that the risks of running acme.sh as root are less than the risks of more exposure of admin password.

Leave a Reply

Your email address will not be published. Required fields are marked *