QcKnownServers Class
The servers this installation trusts (decision E-872), like SSH's known_hosts: the fingerprint of each server's certificate (QcTlsFingerprint), pinned at the first connection (trust on first use) under the normalised address (keyOf(): every spelling of one address is one pin). More...
| Header: | #include <clientcore/network/QcKnownServers.h> |
Public Types
Public Functions
| QcKnownServers::Trust | check(const QcServerAddress &address, const QByteArray &fingerprint) const |
| std::optional<QcKnownServers::Entry> | find(const QcServerAddress &address) const |
| QcStatus | forget(const QcServerAddress &address) |
| QcStatus | load() |
| QcStatus | remember(const QcServerAddress &address, const QByteArray &fingerprint) |
Static Public Members
| QString | defaultPath() |
| const char[19] | fileName |
| QString | keyOf(const QcServerAddress &address) |
Detailed Description
A server that later shows another certificate is refused until the player forgets the pin. Kept as JSON in <data>/known-servers.json, readable only by the user; the file is read anew for every join.
Member Type Documentation
enum class QcKnownServers::Trust
How a server's certificate compares with its pin.
| Constant | Value | Description |
|---|---|---|
QcKnownServers::Trust::New | 0 | No pin for this address yet. |
QcKnownServers::Trust::Known | 1 | The pinned certificate. |
QcKnownServers::Trust::Changed | 2 | Another certificate than the pinned one. |
Member Function Documentation
QcKnownServers::Trust QcKnownServers::check(const QcServerAddress &address, const QByteArray &fingerprint) const
Returns how the certificate with fingerprint compares with the pin of address.
[static] QString QcKnownServers::defaultPath()
Returns the file's place: <data root>/known-servers.json (QcDataRoot).
std::optional<QcKnownServers::Entry> QcKnownServers::find(const QcServerAddress &address) const
Returns the pin of address; nothing when there is none.
QcStatus QcKnownServers::forget(const QcServerAddress &address)
Drops the pin of address and writes the file. Returns the error when the file cannot be written; nothing to drop is no error.
[static] QString QcKnownServers::keyOf(const QcServerAddress &address)
Returns the key of address, "host:port": a name in lower case, an IP address in Qt's canonical form (IPv6 in brackets, "[2a02:db8::1]" for "2A02:0DB8:0::1").
QcStatus QcKnownServers::load()
Reads the file. Returns an error for a damaged file; a missing file is an empty list (it is not overwritten: the pins would be lost).
QcStatus QcKnownServers::remember(const QcServerAddress &address, const QByteArray &fingerprint)
Pins fingerprint for address and writes the file. Returns the error when the file cannot be written.
Member Variable Documentation
const char[19] QcKnownServers::fileName
The file's name in the data root.