WIP-0012: HTTPS for Offline Whitebox¶
Introduction¶
Some browser features, such as
Screen Wake Lock,
only work on pages served over trusted HTTPS. Phones and tablets currently open
Whitebox at http://10.42.0.1, so these features are unavailable.
A browser trusts a certificate only if a public certificate authority (CA), such as Let's Encrypt, issued it for a public domain name. The CA must first check that we control that name, which needs Internet access. Whitebox is offline during flights, but it is online during installation and updates, and usually again after a flight.
This WIP proposes giving each box its own name under wbox.aero, getting a
certificate for that name while the box is online, and serving HTTPS from the box
over its own Wi-Fi during the flight.
Goals¶
- Open Whitebox on a phone without installing anything or accepting a security warning.
- Keep all traffic between the phone and the box on the box's Wi-Fi.
- Keep DNS credentials off the boxes.
- Let the owner choose the box's name.
Overview¶
The examples use a box named skyhawk:
- Hostname:
skyhawk.wbox.aero - Box address on its own Wi-Fi:
10.42.0.1, which is the same on every box
| Part | Where it runs | What it does |
|---|---|---|
| Box | Orange Pi | Keeps its private keys and serves Whitebox over HTTPS |
| Certificate service | A server we host, always online | Registers box names and gets certificates from the CA for them |
wbox.aero DNS zone |
A DNS provider | Holds the records the CA checks |
| Let's Encrypt | Internet | Issues the certificates |
wbox.aero is used only for boxes, which keeps them apart from the
whitebox.aero website. For people who mix up the two domains, a small server
we host redirects any <name>.whitebox.aero that doesn't exist to
<name>.wbox.aero, using a wildcard DNS record and certificate. Since box names
have no public record, this only helps a phone on the box's Wi-Fi while the box
itself is online.
Why a separate certificate service¶
The box has no public address, so the CA cannot connect to it. Instead, the CA
uses a DNS check: it gives us a random value and expects to find it in a TXT
record at _acme-challenge.skyhawk.wbox.aero. Whoever can write that record can
get a certificate for the name.
If every box could write these records, anyone who copied the DNS credentials
from one box could get certificates for every other box's name. So only the
certificate service writes them, and it only does so for the name registered to
the box asking. Since wbox.aero holds nothing but boxes, the service's DNS API
token can cover that whole zone without being able to change the website or mail
records of whitebox.aero. Box names have no other public DNS records, so
registering a box needs no DNS change.
Registering a box¶
Registration happens during installation, which already needs Internet: the install script downloads Whitebox, Docker and system updates.
- The installer reads
WHITEBOX_NAMEfrom/whitebox/.env, which may be empty. - The box creates a key pair, its device key, and sends the requested name, if any, and the public half of the key to the service.
- If no name was requested, the service picks a free one with
coolname, such as
mellow-mantis. If the requested name is free, the service uses it; if it is taken, the installer reports it so the owner can pick another. The service recordsskyhawk → device public keyand confirms the name. - From then on, the service accepts certificate requests for
skyhawkonly when they are signed with that device key.
Names are first come, first served. A name belongs to a device key, not to a person: a box that loses its device key, for example after a fresh install without a backup, cannot reclaim its name by itself, and a maintainer has to release it on the service. User accounts would let owners manage their names themselves (recover a name, move it to a new box) and are left for later.
The name is public: anyone can see it in the public logs of issued certificates. Owners should not use a name they want to keep private, such as an aircraft registration.
Getting a certificate¶
While the box is online:
Box Certificate service Let's Encrypt
|-- certificate request ------>| |
| for skyhawk, signed with |-- order for skyhawk ------------>|
| the device key |<-- value to publish -------------|
| |-- write TXT record in |
| | wbox.aero |
| |-- ready to check --------------->|
| | CA reads TXT record |
| |<-- certificate ------------------|
|<-- certificate --------------| |
The box has a second key pair, its HTTPS key, separate from the device key. It
creates a certificate signing request (CSR) for skyhawk.wbox.aero, signed with
the HTTPS private key, and sends it signed with the device key. The service
passes the CSR to the CA unchanged. Neither private key leaves the box, so the
service only handles public keys and certificates. The service talks to the CA
with certbot's acme Python library rather
than its own code; it accepts a CSR created elsewhere and reads ACME Renewal
Information for renewal timing.
The box installs the certificate in nginx, which today serves Whitebox over HTTP on port 80, and reloads it. It keeps the previous certificate in use until the new one is in place and the nginx configuration check passes.
Using it offline during a flight¶
Phone joins the box's Wi-Fi
Phone opens skyhawk.wbox.aero
Phone asks where that is -> box answers 10.42.0.1
Phone connects to it -> box presents its certificate
Phone checks the certificate against the CAs it already trusts -> page loads
None of this needs the Internet. nginx must send the full certificate chain, since a phone that has never seen it cannot download the missing part offline.
The access point uses NetworkManager's shared mode
(setup),
which already runs dnsmasq as the DNS server for connected phones. One line,
address=/skyhawk.wbox.aero/10.42.0.1, makes it answer for this box's name.
It does not answer other box names, so those fail instead of reaching the wrong
box.
On Android, a Wi-Fi network without Internet may not become the phone's default
network until the user chooses to stay connected to it. Until then the phone
sends its traffic over mobile data and cannot reach the box at any address, as
with http://10.42.0.1 today. This proposal does not change that.
How users find the address¶
Users open skyhawk.wbox.aero, or whitebox.local if they don't remember the
name.
whitebox.local is the same on every box. Phones look up .local names with
multicast DNS rather than asking dnsmasq, so the box announces the name with
Avahi. Older Android versions may not resolve it; 10.42.0.1 keeps working
there. nginx answers skyhawk.wbox.aero, whitebox.local and 10.42.0.1 the
same way over HTTP, since a typed name can arrive over HTTP (older browsers, or
a browser falling back after a certificate error):
- With a valid certificate, it redirects (307) to
https://skyhawk.wbox.aero. - Without one (not created yet, or expired), it shows a page saying that the box needs Internet to get its certificate, and switches to HTTPS once it has one.
Whitebox itself is only served over HTTPS. There is no mode where it runs over
HTTP with some features missing. A phone that opens https://skyhawk.wbox.aero
directly while the certificate has expired gets a browser certificate error
instead of that page; the user has to open whitebox.local or 10.42.0.1.
What else has to change¶
An HTTPS page cannot load anything over plain HTTP. Live preview currently talks
to SRS directly over HTTP on port 1985 (LiveStream360WebRTC.jsx), so it has to
go through nginx over HTTPS instead. Other services that the browser reaches on
their own ports need the same check. Django needs the hostname in
DJANGO_ALLOWED_HOSTS and its trusted origins.
Renewal and how long a box can stay offline¶
Let's Encrypt certificates last 90 days today, 64 days from 10 February 2027 (announcement) and 45 days from 2028 (announcement). Other public CAs follow the same industry limits, which fall to 100 days in March 2027 and 47 days in March 2029, so another CA would only buy a little time.
Whenever the box is online, it asks the service once a day whether renewal is due, and right away when it comes online without a valid certificate. The service decides using ACME Renewal Information, where the CA tells it when to renew, which is about two thirds of the way through the certificate's lifetime. Renewal is the same request as the first certificate, so the service writes a new TXT record each time.
The time a box can stay offline is therefore the time left on its certificate when it goes offline: with 64-day certificates, about 64 days just after a renewal and about 21 days just before one. Once it runs out, Whitebox cannot be used until the box is back online and renews; until then it only shows the page asking for Internet. The UI should show the expiry date and warn well before it, so the owner can connect the box before a trip.
Alternatives considered¶
- Self-signed certificate or our own CA: every phone would have to install and trust it first.
- Certificate for
10.42.0.1or a.localname: public CAs do not issue certificates for private addresses or local names. - One certificate and key shared by all boxes, for a shared HTTPS name: anyone
could copy the key from one box and impersonate all of them, and the CA would
revoke the certificate once that happened, as it did for Netgear's
routerlogin.net. All boxes would also share one browser origin, so cookies and stored data would carry over between them. - Each box writes its own DNS records: puts DNS credentials on every box (see Why a separate certificate service).
- Cloud tunnel: needs Internet during the flight.
Open decisions¶
Let's Encrypt issues at most 50 new certificates per week under wbox.aero.
Renewals for the same name don't count, so this only limits how
many new boxes can register per week. More would need a limit increase.