FreydNot
New Around Here
This isn't a detailed howto. It's more like my notes about what I did to make it work. You should probably know what you are doing before attempting this. I've cobbled this together from various pages on the internet. Nothing is original to me. I am standing on the shoulders of giants.
Why? No good reason really. I've always enabled Web Access from WAN and HTTPS authentication method so I can access my home router from work (or while I'm out and about). It has always bothered me that the certificate isn't considered valid by the web browser.
For this to work you need to have access to a linux system inside your network. Yes, that's cheating. Fortunately for me I already had a Ubuntu VM running a Nagios that I could easily leverage.
For this howto, swap occurances of router.example.com with the publically resolvable host name you've set up for your router. See the WAN - DDNS part of the router web interface for more info.
Part 1: port 443 redirection
Really you should do this just before you run letsencrypt-auto, but layout wise it fits better here...
On the router, go to WAN and then Virtual Server / Port Forwarding
set a rule that forwards port 443 to the linux VM you are installing Let's Encrypt on.
Part 2: Install Let's Encrypt on the Ubuntu VM (that already has apache2 set up and running)
Install git
Get Let’s Encrypt
Run Let's Encrypt for the first time and have it make a dummy cert. You are only allowed to generate 5 legit certs a week, so it's good to start out with a testing cert that doesn't count against your allowance.
It's going to install a lot of dependencies (like a lot). Just let it do it's thing. If it asks you any questions, answer them appropriately.
If there were any problems, correct them before proceeding.
Run it again without the test-cert flag to create a real certificate.
Assuming everything went okay, you will now find your certificate files in /etc/letsencrypt/live/router.example.com/
Now that the cert is made, you can turn off the port 443 redirection.
Part 3: Put the certs on the router
Open a shell on your router and verify https_crt_save is set to zero
Set https_crt_save to 1 and check to make sure it stuck.
Put the contents of /etc/letsencrypt/live/router.example.com/privkey.pem (from your Ubuntu system) into /etc/key.pem on the router. Don't worry if something is already there, just delete it all first.
Put the contents of /etc/letsencrypt/live/router.example.com/fullchain.pem (from your Ubuntu system) into /etc/cert.pem on the router. Don't worry if something is already there, just delete it all first.
Verify https_crt_file is not set to anything
Restart httpd on the router
Check that https_crt_file is no longer empty (it should answer back with several lines of what looks like random characters).
If you are a belt and suspenders type of person, go ahead and reboot the router (just for fun).
Part 4: Verify it worked
Point your browser to your https login page and make sure you don't get a warning about the certificate being invalid.
Part 5: Renew the cert
Let's Encrypt certs are only good for 90 days, so you will have to do this process over again every 3 months (or sooner). Realistically, the next time you need to log into your router you'll notice it's expired and go do something about it.
To renew the cert, do the whole thing over again from part 1 to part 4. This time you should use this command so it won't ask all the questions again.
That's it. Good luck.
Why? No good reason really. I've always enabled Web Access from WAN and HTTPS authentication method so I can access my home router from work (or while I'm out and about). It has always bothered me that the certificate isn't considered valid by the web browser.
For this to work you need to have access to a linux system inside your network. Yes, that's cheating. Fortunately for me I already had a Ubuntu VM running a Nagios that I could easily leverage.
For this howto, swap occurances of router.example.com with the publically resolvable host name you've set up for your router. See the WAN - DDNS part of the router web interface for more info.
Part 1: port 443 redirection
Really you should do this just before you run letsencrypt-auto, but layout wise it fits better here...
On the router, go to WAN and then Virtual Server / Port Forwarding
set a rule that forwards port 443 to the linux VM you are installing Let's Encrypt on.
Part 2: Install Let's Encrypt on the Ubuntu VM (that already has apache2 set up and running)
Install git
Code:
sudo apt-get install git
Get Let’s Encrypt
Code:
cd ~/
git clone https://github.com/letsencrypt/letsencrypt
Run Let's Encrypt for the first time and have it make a dummy cert. You are only allowed to generate 5 legit certs a week, so it's good to start out with a testing cert that doesn't count against your allowance.
Code:
sudo ~/letsencrypt/letsencrypt-auto --test-cert -d router.example.com
It's going to install a lot of dependencies (like a lot). Just let it do it's thing. If it asks you any questions, answer them appropriately.
If there were any problems, correct them before proceeding.
Run it again without the test-cert flag to create a real certificate.
Code:
sudo ~/letsencrypt/letsencrypt-auto -d router.example.com
Assuming everything went okay, you will now find your certificate files in /etc/letsencrypt/live/router.example.com/
Now that the cert is made, you can turn off the port 443 redirection.
Part 3: Put the certs on the router
Open a shell on your router and verify https_crt_save is set to zero
Code:
admin@RT-AC68U:/tmp/home/root# nvram get https_crt_save
0
Code:
admin@RT-AC68U:/tmp/home/root# nvram set https_crt_save=1
admin@RT-AC68U:/tmp/home/root# nvram get https_crt_save
1
Put the contents of /etc/letsencrypt/live/router.example.com/fullchain.pem (from your Ubuntu system) into /etc/cert.pem on the router. Don't worry if something is already there, just delete it all first.
Verify https_crt_file is not set to anything
Code:
admin@RT-AC68U:/tmp/home/root# nvram get https_crt_file
admin@RT-AC68U:/tmp/home/root#
Restart httpd on the router
Code:
admin@RT-AC68U:/tmp/home/root# service restart_httpd
Check that https_crt_file is no longer empty (it should answer back with several lines of what looks like random characters).
Code:
admin@RT-AC68U:/tmp/home/root# nvram get https_crt_file
H4sIAG1T91YCA+1XybKjyJKtNV9Re1m3GMSgxVsEM0IgMQ87JjE...
If you are a belt and suspenders type of person, go ahead and reboot the router (just for fun).
Part 4: Verify it worked
Point your browser to your https login page and make sure you don't get a warning about the certificate being invalid.
Part 5: Renew the cert
Let's Encrypt certs are only good for 90 days, so you will have to do this process over again every 3 months (or sooner). Realistically, the next time you need to log into your router you'll notice it's expired and go do something about it.
To renew the cert, do the whole thing over again from part 1 to part 4. This time you should use this command so it won't ask all the questions again.
Code:
sudo ~/letsencrypt/letsencrypt-auto renew -d router.example.com
That's it. Good luck.