1
0
mirror of https://github.com/aziascreations/BakaShrot.git synced 2026-11-23 20:58:46 +01:00

Merged bakashrot-cert into bakashrot as bakashrot cert, Made the programs smaller, Added a -HybridCrt switch

- `bakashrot cert ca|issue|revoke|show` (same options) replaces
  bakashrot-cert: aws-lc, the C runtime and clap once, 2.53 MB instead
  of 2.85 + 1.73 MB on Windows; guides, docs, release.py, Docker updated
- The tool built with its own profile, release-tools (panic = "abort",
  about 15% smaller); the DLL and the server keep unwind
- clap without colours and suggestions (40 KB, 9 crates fewer)
- SQLite without FTS3/FTS5, R-Tree, dbstat, STAT4, soundex(), extension
  loading and column metadata (LIBSQLITE3_FLAGS): the server 4.68 to
  4.37 MB; a storage test checks they're out
- build.ps1 / release.ps1 -HybridCrt (.cargo/hybrid-crt.toml): the UCRT
  from Windows, about 180 KB less per program, still nothing to install;
  static stays the default, README.txt says which
- revamp.md: what was weighed and left (UPX, fully dynamic CRT, nightly
  options, OMIT_* flags), aws-lc kept over Graviola (490 KB bigger) and
  ring (no ML-KEM)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-17 21:13:58 +01:00
parent 8597ef0aa8
commit 5b41a06d0c
26 changed files with 253 additions and 219 deletions
+7 -7
View File
@@ -2,7 +2,7 @@
Who connects to whom, and how it's checked. The code is
`crates/bakashrot-pki` (the library) and `crates/bakashrot-tools`
(`bakashrot-cert`, the tool). Decided in `../revamp.md`, "Decided".
(`bakashrot cert`, the tool's commands). Decided in `../revamp.md`, "Decided".
## The idea
@@ -68,7 +68,7 @@ connected, `peer_identity()` gives the other end's `Identity`.
## Revocation
- `bakashrot-cert revoke` writes `ca.crl`, signed by the CA, with every
- `bakashrot cert revoke` writes `ca.crl`, signed by the CA, with every
certificate revoked before (written aside, then moved in place).
- A server reads it into `Revocations`, which its TLS setup shares
(`SharedRevocations`): replacing what's inside takes effect for the next
@@ -95,11 +95,11 @@ connected, `peer_identity()` gives the other end's `Identity`.
## The tool
```
bakashrot-cert ca --name "Home CA" ca.crt, ca.key
bakashrot-cert issue --name kitchen --role sensor kitchen.crt, kitchen.key
bakashrot-cert issue --name server-1 --role peer --server
bakashrot-cert revoke kitchen.crt ca.crl
bakashrot-cert show kitchen.crt
bakashrot cert ca --name "Home CA" ca.crt, ca.key
bakashrot cert issue --name kitchen --role sensor kitchen.crt, kitchen.key
bakashrot cert issue --name server-1 --role peer --server
bakashrot cert revoke kitchen.crt ca.crl
bakashrot cert show kitchen.crt
```
`--ca` (the folder of `ca.crt` / `ca.key`, `.` by default), `--out` (where
+10 -9
View File
@@ -9,7 +9,7 @@ What apps connect with, in layers:
| C header | `bindings/c/bakashrot.h` | generated from the DLL (cbindgen) |
| PureBasic | `bindings/purebasic/` | the prototypes and the error codes |
| Python | `bindings/python/bakashrot.py` | `Client` over the DLL (ctypes), standard library only |
| The tools | `crates/bakashrot-tools`: `bakashrot` | the command line, over `bakashrot-client` |
| The tool | `crates/bakashrot-tools`: `bakashrot` | the command line, over `bakashrot-client`; `bakashrot cert`, the certificates |
Decided in `../revamp.md`, "Decided" (2026-11-13). What goes over the
wire: `protocol.md`; the server's side: `server.md`.
@@ -20,14 +20,14 @@ names, queries.
## Who connects: certificates
A client is its certificate, issued by the CA the servers trust
(`certificates.md`, `bakashrot-cert issue`): its name is its node, its
(`certificates.md`, `bakashrot cert issue`): its name is its node, its
roles say what it may do on each server (`config.md`). It needs the CA's
certificate (to check the server's), its own certificate and key, and the
CA's CRL if there is one (servers it revokes are refused).
### `client.toml`
What Python's `Client.from_file()` and the tools read. Paths are relative
What Python's `Client.from_file()` and the tool read. Paths are relative
to the file's folder.
```toml
@@ -108,13 +108,14 @@ getters. Run directly, it's an example: `ClientExample <DllPath> <CaFile>
with an attachment, reading both back (run by hand against a server;
not in CI, which has no PureBasic).
## The tools
## The tool
`bakashrot`, one program to push, read, query and list (`bakashrot-cert`,
for the CA, is apart: `certificates.md`). Each command connects with
`-c <file>` (`client.toml` by default), does one thing and exits: 0, 1 on a
failure (why on stderr: `Refused by the server (NotAllowed): ...`,
`Failed to connect to ...`), 2 on bad arguments. `--help` on each.
`bakashrot`, one program to push, read, query and list, and to make the
certificates (`bakashrot cert`, no server needed: `certificates.md`).
Each other command connects with `-c <file>` (`client.toml` by default),
does one thing and exits: 0, 1 on a failure (why on stderr: `Refused by
the server (NotAllowed): ...`, `Failed to connect to ...`), 2 on bad
arguments. `--help` on each.
```text
bakashrot push logs '{"t":21}' Pushed as message #42
+8 -8
View File
@@ -10,7 +10,7 @@ example configs.
| Machine | What runs there | Files it gets |
|---|---|---|
| admin (any) | `bakashrot-cert` | `ca.key` stays here, never copied |
| admin (any) | `bakashrot cert` | `ca.key` stays here, never copied |
| server-1 | `bakashrot-server` | `ca.crt`, `server-1.crt`, `server-1.key`, `server.toml` |
| server-2 | `bakashrot-server` | `ca.crt`, `server-2.crt`, `server-2.key`, `server.toml` |
| kitchen | `bakashrot` (pushes to server-1) | `ca.crt`, `kitchen.crt`, `kitchen.key`, `client.toml` |
@@ -23,12 +23,12 @@ their hostnames or IPs. The clients can be on the servers' machines.
## 1. The certificates (admin)
```
bakashrot-cert ca --name "Lab CA"
bakashrot-cert issue --name server-1 --role peer --server
bakashrot-cert issue --name server-2 --role peer --server
bakashrot-cert issue --name kitchen --role sensor
bakashrot-cert issue --name dashboard --role dashboard
bakashrot-cert issue --name lab-py --role sensor --role dashboard
bakashrot cert ca --name "Lab CA"
bakashrot cert issue --name server-1 --role peer --server
bakashrot cert issue --name server-2 --role peer --server
bakashrot cert issue --name kitchen --role sensor
bakashrot cert issue --name dashboard --role dashboard
bakashrot cert issue --name lab-py --role sensor --role dashboard
```
A certificate is its name (the node) and its roles; the servers' configs
@@ -154,7 +154,7 @@ Failed to connect to server-1.lab:7000 (NotAllowed): none of visitor's roles (gu
takes them; it logs once that server-2 refused), start server-2: within
about 10 s every one is on dashboard, in order.
**Revoking.** On admin, `bakashrot-cert revoke dashboard.crt` writes
**Revoking.** On admin, `bakashrot cert revoke dashboard.crt` writes
`ca.crl`; copy it next to each server's `server.toml` (the `crl` above).
Within 5 s they reload it (`INFO ca.crl: reloaded, 1 revoked`), and the
certificate is refused, at its next connection or request:
+6 -4
View File
@@ -50,12 +50,13 @@ Restart=on-failure
`docker/Dockerfile` (its comments have the details), the image
`ghcr.io/aziascreations/bakashrot-server` (amd64 and arm64, pushed by CI
on a version tag): the server, with `bakashrot` and `bakashrot-cert`
beside it, on `debian:trixie-slim`, as uid 10001.
on a version tag): the server, with the `bakashrot` tool beside it
(`bakashrot cert` for the certificates), on `debian:trixie-slim`, as
uid 10001.
- **The config** in `/etc/bakashrot`, read-only: `server.toml`, the
certificates, the server's key (readable by uid 10001: `chown 10001`
it, `bakashrot-cert` writes keys for their owner only). `listen =
it, `bakashrot cert` writes keys for their owner only). `listen =
"0.0.0.0:7000"`: 127.0.0.1 isn't reachable from outside.
- **The database** in `/var/lib/bakashrot`, a volume: `database =
"/var/lib/bakashrot/bakashrot.sqlite"`.
@@ -64,7 +65,8 @@ beside it, on `debian:trixie-slim`, as uid 10001.
7000:7000 -v ./config:/etc/bakashrot:ro -v
bakashrot-data:/var/lib/bakashrot <image>`. `docker stop` is SIGTERM:
a clean stop. The logs: `docker logs`.
- **The tools:** `docker run --rm <image> bakashrot-cert ...`.
- **The tool:** `docker run --rm <image> bakashrot cert ...` (or
`bakashrot push ...`).
- **Checked** by `docker/test.sh <image>` (CI runs it on both before
pushing): certificates by the image's tool, its server, a push read
back over a Docker network, `docker stop` ending it cleanly.
+8 -1
View File
@@ -159,6 +159,9 @@ SELECT * FROM messages WHERE topic = 'logs' AND node = 'kitchen'
SELECT message_data ->> '$.temp' FROM messages WHERE topic = 'sensors' AND is_json = 1
```
SQLite's functions are there, JSON's included; not `soundex()` nor the
`dbstat` table (left out of the build, "The file").
- **By topic, or topic and node:** ranges of the table, read in order (a
test checks the plans).
- **Filters on `pushed_at` or `message_id`** read the streams they're in,
@@ -182,7 +185,11 @@ SELECT message_data ->> '$.temp' FROM messages WHERE topic = 'sensors' AND is_js
foreign keys: one writer keeps the tables consistent, `CHECK`s keep the
values valid.
- SQLite is compiled in (`rusqlite`'s `bundled`): the same version
everywhere, no system library.
everywhere, no system library. Without full-text search (FTS3, FTS5),
R-Tree, `dbstat`, STAT4, `soundex()`, extension loading and column
metadata, which libsqlite3-sys turns on and nothing here uses: 310 KB
less in the server (`LIBSQLITE3_FLAGS` in `../.cargo/config.toml`; a
test checks they're out). JSON is SQLite's own, always there.
## Measured