metropolis: reduce usage of identity.NodeID
Eventually, we want to be able to rotate node keypairs. To allow this,
the node ID needs to become independent of the public key. This change
is a refactoring which starts this work by reducing the usage of
identity.NodeID, the function which derives a node ID from a public key.
Change-Id: I5231ed0a7be37c23327fec93481b00c74374af07
Reviewed-on: https://review.monogon.dev/c/monogon/+/3445
Tested-by: Jenkins CI
Reviewed-by: Lorenz Brun <lorenz@monogon.tech>
diff --git a/metropolis/node/core/rpc/client.go b/metropolis/node/core/rpc/client.go
index 5fc76e3..72122b7 100644
--- a/metropolis/node/core/rpc/client.go
+++ b/metropolis/node/core/rpc/client.go
@@ -39,15 +39,12 @@
if err != nil {
return fmt.Errorf("server presented unparseable certificate: %w", err)
}
- pkey, err := identity.VerifyNodeInCluster(serverCert, ca)
+ id, err := identity.VerifyNodeInCluster(serverCert, ca)
if err != nil {
return fmt.Errorf("node certificate verification failed: %w", err)
}
- if nodeID != "" {
- id := identity.NodeID(pkey)
- if id != nodeID {
- return fmt.Errorf("wanted to reach node %q, got %q", nodeID, id)
- }
+ if nodeID != "" && id != nodeID {
+ return fmt.Errorf("wanted to reach node %q, got %q", nodeID, id)
}
return nil
diff --git a/metropolis/node/core/rpc/peerinfo.go b/metropolis/node/core/rpc/peerinfo.go
index 6a8443b..55f949c 100644
--- a/metropolis/node/core/rpc/peerinfo.go
+++ b/metropolis/node/core/rpc/peerinfo.go
@@ -11,7 +11,6 @@
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
- "source.monogon.dev/metropolis/node/core/identity"
epb "source.monogon.dev/metropolis/proto/ext"
)
@@ -51,8 +50,8 @@
// PeerInfoNode contains information about a Node on the other side of a gRPC
// connection.
type PeerInfoNode struct {
- // PublicKey is the ED25519 public key bytes of the node.
- PublicKey []byte
+ // ID is the node identifier.
+ ID string
// Permissions are the set of permissions this node has.
Permissions Permissions
@@ -121,7 +120,7 @@
}
switch {
case p.Node != nil:
- return fmt.Sprintf("node: %s, %s", identity.NodeID(p.Node.PublicKey), p.Node.Permissions)
+ return fmt.Sprintf("node: %s, %s", p.Node.ID, p.Node.Permissions)
case p.User != nil:
return fmt.Sprintf("user: %s", p.User.Identity)
case p.Unauthenticated != nil:
diff --git a/metropolis/node/core/rpc/server_authentication.go b/metropolis/node/core/rpc/server_authentication.go
index eed7dba..37c8fad 100644
--- a/metropolis/node/core/rpc/server_authentication.go
+++ b/metropolis/node/core/rpc/server_authentication.go
@@ -161,7 +161,7 @@
return nil, status.Errorf(codes.Unauthenticated, "certificate not signed by cluster CA: %v", err)
}
- nodepk, errNode := identity.VerifyNodeInCluster(cert, s.NodeCredentials.ClusterCA())
+ id, errNode := identity.VerifyNodeInCluster(cert, s.NodeCredentials.ClusterCA())
if errNode == nil {
// This is a Metropolis node.
np := s.nodePermissions
@@ -170,7 +170,7 @@
}
return &PeerInfo{
Node: &PeerInfoNode{
- PublicKey: nodepk,
+ ID: id,
Permissions: np,
},
}, nil