From 944a35d200c9b22ad6a81cadd06c45ee64bd9f8f Mon Sep 17 00:00:00 2001 From: jochen Date: Mon, 26 Oct 2026 19:23:06 +0100 Subject: [PATCH] =?UTF-8?q?A=20node's=20record=20carries=20the=20mesh's=20?= =?UTF-8?q?own=20certificate=20as=20the=20machine=20holds=20it,=20and=20fr?= =?UTF-8?q?ombus=20composes=20with=20the=20composing=20node's=20(issue=201?= =?UTF-8?q?126,=20ADR=200555=20=C2=A73)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- go/compose/frombus/frombus.go | 14 ++++++++++++++ go/compose/frombus/frombus_test.go | 3 ++- go/delivery/noderecord.go | 3 +++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/go/compose/frombus/frombus.go b/go/compose/frombus/frombus.go index 44cde19..67f2c1e 100644 --- a/go/compose/frombus/frombus.go +++ b/go/compose/frombus/frombus.go @@ -106,6 +106,20 @@ func Input(ctx context.Context, r Reader, mesh Mesh, s Scope) (compose.Input, er in := compose.Input{OverlayCIDR: mesh.OverlayCIDR, InternalSuffix: mesh.InternalSuffix, Authority: mesh.Authority, Catalogue: map[string]catalogue.Manifest{}} + if in.Authority == "" { + // The mesh's own certificate, public, as the composing node holds it; for the check of every node, as the first + // node holding one does. + if rec, ok := records[s.Node]; ok && rec.Authority != "" { + in.Authority = rec.Authority + } else { + for _, node := range sortedKeys(records) { + if a := records[node].Authority; a != "" { + in.Authority = a + break + } + } + } + } read := func(module, digest string) (catalogue.Manifest, error) { raw, err := r.Manifest(ctx, digest) if err != nil { diff --git a/go/compose/frombus/frombus_test.go b/go/compose/frombus/frombus_test.go index fedc381..b8ca0ef 100644 --- a/go/compose/frombus/frombus_test.go +++ b/go/compose/frombus/frombus_test.go @@ -88,7 +88,7 @@ func TestInput(t *testing.T) { }, records: map[string]delivery.NodeRecord{ "anchor": {Node: "anchor", TunnelKey: keys["anchor"], Capabilities: caps, Contract: 2}, - "laptop": {Node: "laptop", TunnelKey: keys["laptop"], Capabilities: caps}, + "laptop": {Node: "laptop", TunnelKey: keys["laptop"], Capabilities: caps, Authority: "the mesh's certificate"}, }, modules: map[string]delivery.Module{"xterm": {Manifest: digest}, "unread": {}}, manifests: map[string][]byte{digest: xterm}, @@ -127,6 +127,7 @@ func TestInput(t *testing.T) { Tunnels: map[string]compose.FoundTunnel{"anchor": {Tunnel: tun}}, Adopted: &compose.AdoptedTunnel{Tunnel: tun, Hub: "anchor", Adopted: true}, // The controller's order is by address; laptop enrolled under its peer's key, and a person named the other. + Authority: "the mesh's certificate", CarriedPeers: []compose.CarriedPeer{{PublicKey: keys["laptop"], Address: "10.77.0.2", EnrolledAs: "laptop"}, {PublicKey: "peer", Address: "10.77.0.9", Named: "phone"}}, } diff --git a/go/delivery/noderecord.go b/go/delivery/noderecord.go index d7fef79..c22f8b2 100644 --- a/go/delivery/noderecord.go +++ b/go/delivery/noderecord.go @@ -52,6 +52,9 @@ type NodeRecord struct { Networks []catalogue.AttachedNetwork `json:"networks,omitempty"` NetworksSaid bool `json:"networks-said,omitempty"` Contract int `json:"contract,omitempty"` + // Authority is the mesh's own certificate as this machine holds it (public): the one its declaration last wrote where + // a module asked for it. A node composing its own composes a certificate with it (compose.Input.Authority). + Authority string `json:"authority,omitempty"` } func (r NodeRecord) check() error {