Skip to content

SSL and TLS Web UI in thingino

TheQuantumPhysicist edited this page Apr 10, 2025 · 6 revisions

Thingino by default doesn't support SSL/TLS due to resource constraints in cameras. This tutorial shows how to support SSL/TLS by building thingino yourself from source, which is made very easy to do, thanks to the way it works. A reverse proxy can be used (stunnel) for the main Web UI that controls the camera settings, to protect from eavesdropping your root password.

Note that using Wireguard is a much better option. If you can restrict access to your camera Web UI to Wireguard interface or 127.0.0.1/localhost (we'll show in this tutorial how to do it) and then use an SSH tunnel to access your camera, that's a much better and convenient (and equally secure) option that works with the default software.

Before you start:

  1. Make sure you know how to build thingino and deploy it to your camera (this can be done remotely, very convenient, but you need to know how to use build tools). Refer to this tutorial. We assume here that you know how to build and do OTA deploys. Please practice this before starting to mess with new builds with more complex things, like SSL/TLS.

  2. Prepare your SSL/TLS certificates, whether with a self-signed CA (certificate authority) or not. You have to have good knowledge about this topic. This tutorial assumes that you understand how SSL/TLS works.

WARNING: DO NOT use heavy protocols like RSA-4096. Maybe RSA-2048. Cameras cannot really handle too much processing. At least this is the author's observation. Elliptic curve encryption is a good option, but these are less supported in different places. For example, Ed25519 signature scheme isn't supported in MacOS key chain.

  1. Before blocking http (unencrypted) access, make sure you test everything for a while, and make a backup plan. Make sure you don't lock yourself out. To be fair, at worst, SSH should always be accessible to you.

How to add the SSL/TLS encryption to Thingino build:

  1. In your source build dir, find the file local.fragment and add the line BR2_PACKAGE_STUNNEL=y to it. This adds stunnel software to the build, a software that can act as a reverse proxy and that will be the main tool for SSL/TLS.
  2. Compile the camera firmware.
  3. Push the firmware to the camera
  4. Issue your certificate (in case it's self-signed), and concatenate your CA certificate, server private key and signed certificate (nginx and haproxy style) and place that file in /etc/stunnel.pem (with scp -O stunnel.pem root@your-camera-hostname:/etc/)
  5. Edit the file /etc/stunnel/stunnel.conf to the following (clear the file then add the following):
[https]
accept  = 443
connect = 80
cert = /etc/stunnel.pem

[ws]
accept  = 8090
connect = 8089
cert = /etc/stunnel.pem

Notice that we need websocket too for the camera stream. See the this PR for more information on how this matters.

  1. Run stunnel. Now the reverse proxy works. If everything is alright, it usually doesn't write anything in the terminal's stdout/stderr. Note that stunnel starts automatically on startup, so no need to do anything else. But we run stunnel to ensure we have no errors.

  2. You can check with netstat -plunt that port 443 is occupied. If yes, that means our reverse proxy is running.

  3. Visit the https link to your camera's hostname, like https://hostname.local. Again, I'm assuming you've installed your CA in your OS and you know how this works. Restarting the browser helps if your browser acts up.

That's it. Now you can access your camera using SSL/TLS with end-to-end encryption. stunnel will use your local http server as source and feed the requests in the browser. For more information on how this really works, learn more about stunnel and the configuration we provided.

Disabling http access, to restrict access through https

The http server serves by default to 0.0.0.0. If you wish, you can restrict connections to https. To do this, you have to edit the configuration of busybox's httpd server. For that:

  1. Edit the file /etc/httpd.conf
  2. At the TOP, AFTER THE LINE OF H:, add:
A:127.0.0.1
D:*

And restart your camera to reload the configuration (or reload the service). More information on httpd configuration can be found here. You can also restrict connections to only Wireguard subnet by adding more lines like the one A:127.0.0.1, for example, A:10.0.0.0/24, before the line D:*. Think of this as an Access Control List (ACL).

  1. Wiki Home
  2. About the Project
    1. Contributions
    2. Features
    3. Project Philosophy
    4. Releases
  3. Getting Started
    1. FAQ
    2. Hardware Identification
    3. Ingenic USB Cloner
      1. OTG Booting
    4. Installation: General
    5. Installation: No Tools Methods
    6. Resources and Links
    7. Support Community
    8. Troubleshooting
    9. UART Connection
    10. Updating Firmware
    11. Web UI
  4. Supported Cameras
    1. Cameras
    2. 360 AP1PA3
    3. AliExpress LTIA‐37FJZ (Vanhua Z55 module)
    4. AOQEE C1
    5. Aosu C5L
    6. Cinnado
      1. Cinnado D1 2K
      2. Cinnado D1 3K
    7. Dekco DC5L
    8. Eufy
      1. Eufy E210 Outdoor Cam
      2. Eufy E220
    9. Galayou/Wansview
      1. Galayou G2
      2. Galayou G7
      3. Wansview W6
      4. Wansview W7/Galayou Y4
    10. Hualai (Wyze/Atom/Neos/Personal)
      1. Dafang Upgrading for Wyze v2
      2. NEOS conversion
      3. Personalcam
      4. Wyze Cam Pan V1
      5. Wyze Doorbell (V1)
        1. Chime Reverse Engineering
      6. Wyze v2/Neos SmartCam/ATOM Cam 1
      7. Wyze v3
      8. Wyze Accessories
    11. iFlytek XFP301‐M
    12. Jienuo JN-107-AR-E-WIFI
    13. Jooan A6M
    14. LaView L2
    15. LongPlus X07
    16. LSC 3215672
    17. Sannce I21AG
    18. Sonoff Cam‐S2
    19. Wuuk Y0510
    20. Xiaomi
      1. Xiaomi Mijia1080p (SXJ02ZM)
      2. Xiaomi MJSXJ03HL
      3. Xiaomi Outdoor Camera AW200 (MJSXJ05HL)
  5. Configuration
    1. Administration
    2. Automation
    3. Cron jobs
    4. General
    5. LED Indicators
    6. Lighting
    7. Media Streaming Endpoints
    8. Network Storage
    9. Networking
      1. Wireless Networking
      2. USB Direct w CDC
      3. USB Ethernet Networking
      4. Remote Access
      5. VPN
        1. Tailscale
        2. Wireguard
        3. Zerotier
      6. Wi-Fi
        1. Self Hosted AP
        2. Tips and Tricks
      7. WWAN (Cellular)
    10. Night Mode
    11. ONVIF
    12. OSD (On-screen Display)
    13. Plugins
      1. Motion Guard
      2. Yandex Disk
    14. SSH Access Keys
    15. Wi-Fi Access
    16. Provisioning
  6. Integration
    1. Home Assistant
    2. Frigate
    3. Ingenic A1/$15 NVR
    4. Mobile Apps
    5. MQTT Integration
    6. Virtual Webcam on Linux
    7. Mainsail (Klipper)
  7. Development
    1. Booting
      1. Boot: MMC SD
      2. Boot: NFS
    2. CH341A Programmer
    3. RTSP Players
    4. Flash Chips
    5. go2rtc
    6. Porting Guide
    7. Ingenic Platform Capability Matrix
    8. Ingenic Image Processor
    9. ISP Reserved Memory (RMEM)
    10. Debugging
    11. Software
      1. Building From Sources
      2. Buildroot
      3. Toolchain
      4. Choice of JSON library
    12. SSL and TLS Web UI in thingino
    13. Tech Info
      1. Hardware
      2. PWM Info
      3. Supported Hardware
      4. T23 GPIOs
      5. T31 GPIOs
    14. U-Boot Cheatsheet
    15. Zeratul/Atlas/Tassadar
    16. Resources
Clone this wiki locally