TLS/SSL certificates for a server

Transport_Layer_Security (TLS, formerly called SSL) is used to encrypt and protect communication. When a webserver works with regular HTTP protocol i.e. its address starts with http but over the encrypted TLS this called HTTPS and a site address starts with https. For all HTTPS sites a web browser shows a lock icon in an address bar. For enabling HTTPS for a website's domain we need a private key and it's TSL certificate that was signed by a Certificate Authority (CA).

The OpenWrt admin site LICI by default supports the HTTPS so you can open it with httpS://192.168.1.1/. But it's certificate is self signed and not verified by a CA so your browser will show a warning.

You can buy a TLS cert but nowadays the Let's Encrypt CA allows to sign and verify certificates for free with a certbot program that uses ACME protocol. The only problem is that the certificate will have a short period of validity and you have to configure certificate renewal.

There is few ACME clients that automates the cert issuing:

  • certbot is an official ACME client that is feature rich but is too heavy for small OpenWrt routers.
  • acme.sh is small ACME client that uses shell script and has a LUCI app to configure. This is a recommended for OpenWrt.
  • uacme lightweight ACME client written in plain C with minimal dependencies: libcurl and one of MbedTLS, OpenSSL or GnuTLS.
  • dehydrated a Bash script similar to acme.sh. Used rarely

Use a command line and type opkg install acme luci-app-acme then edit /etc/config/acme and restart it with service acme restart.

Open LUCI dashboard then in main menu go to System / Software. Then click on Update lists… to load list of available packages. The into the Filter search type luci-app-acme and press Enter. Click on install button. It should install acme.sh and its LUCI app to configure.

To configure in LUCI in the main menu open Services / ACME certs. Basic configuration:

  • Account email: put your email to receive expiry notices when your certificate is coming up for renewal.
  • You'll see a preconfigured EXAMPLE domain. We can change it for ourselves:
  • Enabled: Click to enable
  • Use staging server: unselect the check
  • Use for uhttpd: you probably better to unselect this if not sure.
  • Key size: Select ECC 256 bits. The key will be based on an elliptic curve which is more efficient than RSA.
  • Domain names: change the example.org to your domain
  • Click on Save and Apply

Now you'll need to wait for some time while the certificate will be generated. After that you can find the certificates in /etc/acme/YOURDOMAIN folder e.g.:

  • /etc/acme/YOURDOMAIN/YOURDOMAIN.key the TLS private key. Never share it!
  • /etc/acme/YOURDOMAIN/fullchain.cer the TLS certificate and chain of CA that signed it.

You can use them in nginx, uhttpd, lighttpd, EmailRelay and any other server that you want to configure with TLS.

This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.More information about cookies
  • Last modified: 2022/07/08 05:48
  • by tmomas