Skip to content

feat(grpc): encrypt the control channel with server-side TLS - #120

Merged
GyulyVGC merged 3 commits into
NullNet-ai:mainfrom
antoncxx:grpc-control-channel-tls
Jul 24, 2026
Merged

feat(grpc): encrypt the control channel with server-side TLS#120
GyulyVGC merged 3 commits into
NullNet-ai:mainfrom
antoncxx:grpc-control-channel-tls

Conversation

@antoncxx

@antoncxx antoncxx commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

On first boot, the control server now generates its own private CA
(members/nullnet-server/grpc-tls/ca-cert.pem + ca-key.pem, created once
and never regenerated) and signs its gRPC TLS leaf cert with it. Copy
ca-cert.pem to every client/proxy host and set CONTROL_SERVICE_CA_CERT
there — it's required: clients pin the channel to that CA and do full
standard chain validation (including hostname matching), so only a leaf
actually signed by it is accepted. Because clients trust the stable CA root
rather than the leaf, rotating the leaf later needs no client-side changes.

The leaf's SAN (needed for hostname validation) is derived in order:
CONTROL_SERVICE_TLS_SAN (explicit override) → the server's own
CONTROL_SERVICE_ADDR (often already the right value) → localhost.

On every boot, a persisted leaf is only reused if it actually verifies
against the persisted CA — issuer/subject match, signature, and expiry are
all checked cryptographically, not just "do the files exist." This catches
a stale leaf left over from an earlier iteration of this feature (before it
signed with a CA at all), or any other corruption/mismatch, and
regenerates just the leaf while keeping the existing CA intact — so
already-distributed client pins keep working.

Known limitation: client authentication (mTLS) remains a follow-up —
the server doesn't yet verify who's connecting, only the reverse.

@antoncxx
antoncxx force-pushed the grpc-control-channel-tls branch 3 times, most recently from ba32d37 to bc48083 Compare July 20, 2026 21:28
@antoncxx
antoncxx marked this pull request as ready for review July 20, 2026 21:53
@GyulyVGC GyulyVGC added the enhancement New feature or request label Jul 21, 2026
@antoncxx
antoncxx force-pushed the grpc-control-channel-tls branch 3 times, most recently from 3d8f346 to d339266 Compare July 21, 2026 23:28
@GyulyVGC

GyulyVGC commented Jul 22, 2026

Copy link
Copy Markdown
Member

@antoncxx is there a way we can simplify the configurations (CONTROL_SERVICE_CA_CERT env, certificate file distribution)?

We're moving towards getting centralised on the server, and before next week deployment it'd be ideal to have the least friction possible.

antoncxx added 2 commits July 23, 2026 23:07
A leftover leaf cert with no matching CA (e.g. from a pre-CA build of
this feature) was being silently reused forever, so ca-cert.pem never
got generated. Now the leaf is cryptographically verified against the
persisted CA (issuer/subject match, signature, expiry) before reuse;
any mismatch regenerates just the leaf, reusing the existing CA so
client pins keep working.
@antoncxx
antoncxx force-pushed the grpc-control-channel-tls branch from 9db5055 to 17dbfdd Compare July 24, 2026 03:14
Client/proxy no longer hard-require the env var — if unset they fall back
to ca-cert.pem in the working directory and only fail once they actually
try to read it (missing file or invalid cert), instead of refusing to
start over an unset variable that already has a sane default.
@antoncxx

Copy link
Copy Markdown
Contributor Author

@GyulyVGC

Client/proxy no longer hard-require the env var — if unset they fall back to ca-cert.pem in the working directory and only fail once they actually try to read it

@GyulyVGC
GyulyVGC merged commit 967bfb1 into NullNet-ai:main Jul 24, 2026
4 checks passed
@antoncxx
antoncxx deleted the grpc-control-channel-tls branch July 24, 2026 14:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants