I have had some success with the acme.sh script on my RT-N66U running firmware version 374.43_48E2j9527. I've run the script, generated a certificate and managed to install it but not yet to survive a reboot.
In case it is useful, I will describe what I have done and what I found helpful.
After looking at various bits of documentation and blog posts, including
https://github.com/acmesh-official/acme.sh, I decided to try to use LetsEncrypt's DNS API mode with the Cloudflare API. I registered for a free Cloudflare account, set my DNS servers to Cloudflare, and set a DNS A record to point to my router: router.pentrehouse.uk. From my Cloudflare dashboard, I generated and made a note of my Cloudflare DNS API token, my Cloudflare account ID and the Cloudflare Zone ID for my domain.
I then logged in to my router using ssh and ran
install-acme.sh
Installing acme.sh to /jffs/acme.sh
rm: can't remove '/jffs/acme.sh-master/dnsapi': Directory not empty
rm: can't remove '/jffs/acme.sh-master': Directory not empty
Updating profile for acme.sh
Installing cron job for auto cert updates
I rebooted as instructed, logged in again, and at the ssh prompt set:
export CF_Token="long hex number"
export CF_Account_ID="another long hex number"
export CF_Zone_ID="one more long hex number"
Where the long hex numbers were the ones copied from my Cloudflare dashboard earlier. I then ran:
acme.sh --issue -d router.pentrehouse.uk --dns dns_cf
and all worked fine and created the certs as follows:
[Tue Mar 16 18:00:52 GMT 2021] Your cert is in /jffs/acme.sh/router.pentrehouse.uk/router.pentrehouse.uk.cer
[Tue Mar 16 18:00:52 GMT 2021] Your cert key is in /jffs/acme.sh/router.pentrehouse.uk/router.pentrehouse.uk.key
[Tue Mar 16 18:00:52 GMT 2021] The intermediate CA cert is in /jffs/acme.sh/router.pentrehouse.uk/ca.cer
[Tue Mar 16 18:00:52 GMT 2021] And the full chain certs is there: /jffs/acme.sh/router.pentrehouse.uk/fullchain.cer
Unlike some later routers I believe, the RT-N66U doesn't include in the GUI the ability to deploy a certificate, so I wanted to do this from the command line. I found a useful blog post and discussion about it at
https://gist.github.com/davidbalbert/6815258
I eventually found that if I copied
/jffs/acme.sh/router.pentrehouse.uk/router.pentrehouse.uk.cer to be /etc/cert.pem and /jffs/acme.sh/router.pentrehouse.uk/router.pentrehouse.uk.key to be /etc/key.pem
and then concatenated the two files to create /etc/server.pem and restarted httpd:
cd /etc
cat key.pem > server.pem
cat cert.pem >> server.pem
service restart_httpd
I could take my browser to
https://router.pentrehouse.uk:8443/ and look at the connection details and there was my certificate. Hoorah!
However, after trying various of the magical utterances from the
https://gist.github.com/davidbalbert/6815258 thread, I have yet to find how to make the certificates survive a reboot. Any suggestions would be very welcome.