acme.sh: An alternative to Let's Encrypt's Certbot¶
Use cases¶
If you have a local service without a public IP address, you can't use the usual Let's Encrypt method. However, there is an alternative method where you prove ownership of your domain by adding a TXT record with a challenge text. For example, you might have a local
- HomeAssistant
- OctoPi / OctoPrint
- PiHole
- paperlessNG
- ...
service in your network that you don't want to expose to the internet (with port forwarding).
Requirements¶
For acme.sh, you need:
- Your own domain registered at a supported DNS provider (see next section)
- A Unix shell
and that's it.
Recommended DNS providers¶
These recommendations are based on my previous experiences:
DNS provider | Recommendation |
---|---|
Porkbun | Yes. Just create your API credentials and you're done. |
Namecheap | No. You have to whitelist your IP address manually from which you access the API. As a static IP from your ISP is not guaranteed for home connections, you always have to change the settings when your IP changes. |
Installation¶
Open the acme.sh GitHub repository. You have multiple installation methods. This is taken from the repository, please check beforehand whether there were changes (and don't just blindly pipe curl to shell!).
Note
After running the installation command, restart your shell so that the alias takes effect.
Method 1¶
alternatively with wget:
Method 2¶
You can also clone the repository and run the shell script:
git clone https://github.com/acmesh-official/acme.sh.git
cd ./acme.sh
./acme.sh --install -m my@example.com
Issue a new certificate¶
We want to create a certificate with API method.
- Read the wiki and check if your DNS provider is supported (the list is split into two pages):
- After you've found your DNS provider, get the necessary credentials (API tokens, API name, etc.)
- Example: Porkbun requires
PORKBUN_API_KEY
andPORKBUN_SECRET_API_KEY
.
- Example: Porkbun requires
-
Open the configuration file located in
~./acme.sh/account.conf
and add the required environment variables.-
Example:
-
-
After that, you can issue a new certificate. Make sure to pass your own DNS provider for the
--dns
argument.-
Example:
-
And you're done! By default, your certificate is located under /home/[username]/.acme.sh/[domain name]
.
Useful arguments¶
With the --reloadcmd [cmd]
argument, you can run a command or shell script after your certificates have been renewed. For example, you can use it to combine the private and public key to a .pem
file: