# HTTPS for Web Services

Source: https://tiltas.openpanel.sh/docs/services/https

> What is on today, what is not yet, and how HTTPS names for Web Services will work.

**Not on yet**

HTTPS names for Web Services are built and tested, but they are **not switched on** at tiltas.openpanel.sh yet. Today
every Web Service answers on `http://name` only, and the console and the API show no HTTPS name (`https` is `null`).
This page describes what changes when it is switched on.

## What works today

- Every Web Service opens at `http://gitea` and `http://gitea.<your Network domain>`.
- That traffic is encrypted end to end between the two Devices by WireGuard, so nothing on the way can read it, even
  though the address starts with `http://`.
- What browsers still do: they mark `http://` pages as not secure, and some web features, such as the camera, the
  clipboard and service workers, work only on HTTPS pages. That is what HTTPS names are for.

## Why it is not on yet

The names need a domain of their own, kept apart from `tiltas.openpanel.sh`, so that a page hosted on one of your Devices
can never share cookies or a site with the console. That domain is not set up yet. Until it is, HTTPS stays off for every
Network.

## How it will work

Once HTTPS is on, each Web Service gets a second address with a publicly trusted certificate:

```text title="HTTPS name" noCopy
https://gitea.0f3a9c1e7b2d4a68.<Service domain>
```

- **`gitea`** is the Service name.
- **`0f3a9c1e7b2d4a68`** is a label of 16 random characters that belongs to the Device hosting the Service. It shows
  neither your Network's name nor anything else about you. Certificates are published in public logs, so this is all
  those logs will ever show.
- **`<Service domain>`** is the domain used only for Service names.

The hosting Device gets one certificate for all its Web Services, from Let's Encrypt. It makes the key itself, keeps it
in its own state directory, and never sends it anywhere: Tiltas only publishes the short-lived DNS record that proves the
name is the Device's. The name resolves only inside your Network, and only while the certificate is valid, so it never
leads to a certificate warning.

`http://gitea` keeps working. Plain HTTP to the HTTPS name moves to `https://`.

## Status in the console

While HTTPS is on, the Service's row in **Services** shows how far its certificate is. The API returns the same as
`https.status`:

| Status | The console shows | Means |
|---|---|---|
| `pending` | HTTPS soon: the Device is getting its certificate | The hosting Device is asking for its certificate. An app too old to know HTTPS stays here until it updates. |
| `ready` | the HTTPS name, with "also http://gitea" under it | The certificate is valid. `url` is now the HTTPS name; `short_url` stays `http://gitea`. |
| `failed` | HTTPS certificate failed, retrying | The last try failed. `https.error` says why. The Device tries again after 5 minutes, then waits longer each time, up to a day. |

The certificate is renewed when a third of its life is left. Signing the Device out deletes the certificate and its key;
a Device that joins again gets a new label.

## What the hosting Device needs

- Outbound HTTPS to the certificate authority.
- An app version with HTTPS support. Older ones keep serving `http://` only.
- Nothing on your router or firewall: the certificate is proven through DNS, not through an open port.

Port 443 of the hosting Device opens to the people who may open its Services only once it holds a valid certificate.
