Enabling SSL for Pi-Hole Admin Interface (lighttpd) UPDATED

Prerequisites

Create Your SSL Certificate

  1. Launch XCA
  2. Open the PKI database if it is not already (File > Open DataBase), enter password
  3. Click on the Certificates tab, right click on your Intermediate CA certificate
  4. Select New
  5. On the Source tab, make sure Use this Certificate for signing is selected
  6. Verify your Intermediate CA certificate is selected from the drop down
  7. Click the Subject tab
  8. Complete the Distinguished Name section

    internalName: Pi-Hole SSL
    countryName: US
    stateOrProvinceName: Virginia
    localityName: Northern
    organizationName: i12bretro
    organizationUnitName: i12bretro Certificate Authority
    commonName: pihole.i12bretro.local

  9. Click the Generate a New Key button
  10. Enter a name and set the key size to at least 2048
  11. Click Create
  12. Click on the Extensions tab
  13. Select End Entity from the type list
  14. Click Edit next to Subject Alternative Name
  15. Add any DNS or IP addresses that the certificate will identify
  16. Update the validity dates to fit your needs
  17. Click the Key Usage tab
  18. Under Key Usage select Digital Signature, Key Encipherment
  19. Under Extended Key Usage select Web Server and Web Client Authentication
  20. Click the Netscape tab
  21. Select SSL Server
  22. Click OK to create the certificate

Exporting Required Files

  1. In XCA, click on the Certificates tab
  2. Right click the Intermediate CA certificate > Export > File
  3. Set the file name with a .pem extension and verify the export format is PEM chain (*.pem)
  4. Click OK
  5. Right click the SSL certificate > Export > File
  6. Set the file name with a .pem extension and verify the export format is PEM + Key (*.pem)
  7. Click OK

Applying the Certificates

  1. If not already installed, Install xrdp to simplify administration by running the following command
    sudo apt-get install xrdp
  2. Connect to the Raspberry Pi via Remote Desktop Client
  3. Copy the certificates exported above to the Pi
  4. Copy the certificates exported above to /etc/lighttpd
    cp ~/Downloads/PiHole.pem /etc/lighttpd
    cp ~/Downloads/ca-chain.pem /etc/lighttpd
  5. Edit lighttpd.conf
    mousepad
  6. File > Open /etc/lighttpd/conf-available/10-ssl.conf
  7. Add/edit the following lines:

    ssl.engine = "enable"
    ssl.pemfile = "/etc/lighttpd/PiHole.pem"
    ssl.ca-file = "/etc/lighttpd/ca-chain.pem"

  8. Optionally, to redirect all http traffic to https, add the following to the end of the file:

    $HTTP["scheme"] == "http" {
    url.redirect = ("" => "https://${url.authority}${url.path}${qsa}")
    }

  9. File > Save > ~/Downloads/10-ssl.conf
  10. In terminal, paste the following commands
    sudo cp ~/Downloads/10-ssl.conf /etc/lighttpd/conf-available/
    sudo ln -s /etc/lighttpd/conf-available/10-ssl.conf /etc/lighttpd/conf-enabled/10-ssl.conf
    sudo service lighttpd restart
  11. Open a web browser and navigate to PiHole via https://