Relays: encryption and trust
Which relays a client reaches with encryption, and which certificates it accepts. The rules are in NETWORK.md section 3; the file names here are the reference's (terse, terse-host, terse node, tersereader), not requirements on other clients.
Encrypted unless written otherwise
A relay written without a scheme is encrypted: relay.example.org means wss://relay.example.org, and relay.example.org:9000 means wss://relay.example.org:9000. A port is only a port; it says nothing about encryption. This holds wherever a relay is written: on a command line (--relay), in the relay list, and in the hints of a feed address.
A plain relay is written with its scheme, ws://host:port, in your own relay list or on your command line. Plain relays are for this machine, a private network and tests. The one exception: localhost or a loopback address without a scheme (127.0.0.1:7878, the local relay) is plain, since its traffic never leaves the machine. A client never takes such an address from the network.
Nothing that goes on the network names a plain relay: a hint has no scheme and always means wss://, a profile lists only wss:// relays (a ws:// line is invalid and skipped), and a client never gives out a plain relay in its address or profile (terse profile set leaves it out and says so). So a client connects without encryption only to relays its user wrote as plain, and a failed encrypted connection is never tried again in plain.
Certificates
An encrypted relay's certificate must come from an authority the client trusts and be for the relay's name. Nothing turns this check off.
For relays the public authorities do not vouch for, the user may set, in their own settings only:
- an authority for every relay: a PEM file in
<config>/authorities/(every*.pemthere),TERSE_RELAY_CA=<file>or--relay-authority <file>; - options for one relay, after it on its line of
<config>/relaysor in a--relayvalue:authority=<file>trusts an authority for that host too;only-authority=<file>trusts only that authority;pin=sha256:<64 hex digits>accepts only the certificate, or the public key, with that fingerprint (terse relay fingerprint <cert.pem>prints both).
With only-authority or pin, nothing else is accepted for that host, a certificate from a public authority included. An option applies only to the host it is written with. A plain relay takes no options.
# <config>/relays wss://relay.tersenet.org wss://relay.corp.example only-authority=corp-ca.pem wss://203.0.113.7:7443 pin=sha256:3b0c⦠ws://192.168.1.20:7878
Nothing received from the network (a hint, a profile, a link, an entry) can add an authority, a pin or a plain connection: those come only from the user.
The Relays page of terse-host's own screens (F10) edits the same list as terse relay add and terse relay remove: a relay typed as on a command line, and its options (pin=, authority=, only-authority=) in the field below it.
A relay on a home or office network
The simple way is plain: terse-relay --listen 0.0.0.0:7878, and ws://192.168.1.20:7878 in each client's relay list. The recommended way is encrypted, with a self-signed certificate that each client pins:
openssl req -x509 -newkey ec -pkeyopt ec_paramgen_curve:P-256 -nodes -days 3650 -subj /CN=relay.home -keyout relay.key -out relay.pem terse-relay --listen 0.0.0.0:7443 --store relay-store --tls-cert relay.pem --tls-key relay.key terse relay fingerprint relay.pem terse relay add wss://192.168.1.20:7443 pin=sha256:ā¦
The pin stands for an authority and for the name check, so the certificate needs no particular name.
When a relay cannot be used, the programs say why: "the relay's certificate is not trusted", "is for another name", "does not match the key pinned for it", "is not from the authority pinned for it", "this relay requires TLS (try wss://)", "this relay does not speak TLS (try ws://)".
Who runs a relay
terse relay info <relay> asks a relay how to reach the people who run it, for example to report something that does not belong there, and prints each contact: line it gives: an e-mail address or a URL, shown as text. A relay whose operator gives none says so, and a relay older than this request gives no answer (gave no info). The same contact is on the page a web browser shows at the relay's address. An operator gives it with terse-relay --contact <text> (README "Running a public relay"); the request is NETWORK.md section 3, "Relay info".