Renew Let's Encrypt Certificate on OpenWRT Router without Opening HTTP Server on WAN Side using ACME.sh
In this article, we will discuss the process of renewing Let's Encrypt certificates on OpenWRT routers without opening the HTTP server on the WAN side. Instead, we will use the ACME.sh client to automate the certificate renewal process. This method is safer and more secure, as it doesn't expose any open ports on the WAN side.
Prerequisites
Before starting the process, make sure you have the following:
- An OpenWRT router with uHTTPd providing a UI on the internal LAN.
- Ports 80 and 443 are blocked on the WAN side for safety.
- An existing Let's Encrypt certificate issued through the ACME.sh client.
Overview of the Process
The process involves the following steps:
- Configuring the uHTTPd server on OpenWRT to listen on the LAN side.
- Setting up a challenge to verify domain ownership through the ACME.sh client.
- Renewing the Let's Encrypt certificate.
- Updating the uHTTPd configuration and reloading the server.
Step 1: Configuring uHTTPd Server on OpenWRT
To configure the uHTTPd server, follow these steps:
- Log in to the OpenWRT router via SSH or the web UI.
- Open the uHTTPd configuration file using your preferred text editor, such as nano or vi.
- Add the following lines to configure the server to listen on the LAN side:
- Save and exit the file.
- Restart the uHTTPd server to apply the changes.
nano /etc/uhttpd.conf
listening_http_port = 80
listening_interface = lan
/etc/init.d/uhttpd restart
Step 2: Setting up a Challenge with ACME.sh
To set up a challenge using the ACME.sh client, follow these steps:
- Install the ACME.sh client if you haven't already done so.
- Generate a new account key for the ACME.sh client.
Execute the following command: - Set up a challenge for your domain using the DNS-01 challenge type.
- Follow the instructions provided by the ACME.sh client to setup DNS records for the DNS-01 challenge.
- Once the DNS-01 challenge is completed successfully, the Let's Encrypt certificate will be generated.
opkg install acme.sh
acme.sh --register-account -m [email protected]
acme.sh --issue --dns dns_cloudflare -d example.com
Step 3: Renewing the Let's Encrypt Certificate
To renew the Let's Encrypt certificate using the ACME.sh client, follow these steps:
- Execute the following command:
- Confirm the renewal by typing 'y' when prompted.
- Once the renewal is completed successfully, the new certificate will be stored in the designated directory.
acme.sh --renew -d example.com
Step 4: Updating uHTTPd Configuration and Reloading the Server
To update the uHTTPd configuration and reload the server, follow these steps:
- Open the uHTTPd configuration file.
- Update the SSL certificate and key paths to the renewed ones.
- Save and exit the file.
- Reload the uHTTPd server to apply the changes.
nano /etc/uhttpd.conf
ssl_cerficate = /path/to/new/certificate.crt
ssl_key = /path/to/new/private.key
/etc/init.d/uhttpd reload
We have discussed the process of renewing Let's Encrypt certificates on OpenWRT routers without opening the HTTP server on the WAN side using the ACME.sh client. This process ensures the safety and security of your network by not exposing any open ports on the WAN side. The process involves configuring the uHTTPd server to listen on the LAN side, setting up a challenge using the ACME.sh client, renewing the Let's Encrypt certificate, and updating the uHTTPd configuration.