Repository navigation
feat(consensus/keys): add keys import and keys export - #1198
Open
leninmehedy wants to merge 1 commit into
Open
leninmehedy wants to merge 1 commit into
leninmehedy wants to merge 1 commit into
Conversation
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
leninmehedy
force-pushed
the
01167-consensus-keys-import-export
branch
from
September 26, 2026 13:48
055af5d to
ae5854f
Compare
leninmehedy
force-pushed
the
01167-consensus-keys-import-export
branch
from
September 26, 2026 14:06
ae5854f to
c16e1fb
Compare
leninmehedy
force-pushed
the
01167-consensus-keys-import-export
branch
from
September 26, 2026 14:13
c16e1fb to
95d08a7
Compare
leninmehedy
force-pushed
the
01167-consensus-keys-import-export
branch
from
September 26, 2026 14:14
95d08a7 to
54380e3
Compare
leninmehedy
force-pushed
the
01167-consensus-keys-import-export
branch
2 times, most recently
from
September 26, 2026 14:41
e3aaeef to
6d577dc
Compare
leninmehedy
force-pushed
the
01167-consensus-keys-import-export
branch
from
September 29, 2026 05:12
6d577dc to
06931e7
Compare
leninmehedy
force-pushed
the
01167-consensus-keys-import-export
branch
from
October 13, 2026 06:27
06931e7 to
d8d804f
Compare
leninmehedy
force-pushed
the
01167-consensus-keys-import-export
branch
from
October 13, 2026 10:33
d8d804f to
a61e70f
Compare
leninmehedy
force-pushed
the
01167-consensus-keys-import-export
branch
4 times, most recently
from
October 13, 2026 12:52
e8a2f34 to
de0c173
Compare
leninmehedy
marked this pull request as draft
October 20, 2026 06:23
leninmehedy
force-pushed
the
01167-consensus-keys-import-export
branch
from
October 21, 2026 03:37
de0c173 to
8987832
Compare
leninmehedy
force-pushed
the
01167-consensus-keys-import-export
branch
from
October 21, 2026 04:44
8987832 to
eae1310
Compare
leninmehedy
force-pushed
the
01167-consensus-keys-import-export
branch
from
October 21, 2026 05:19
eae1310 to
62c0dec
Compare
Add typed Secret I/O and the import/export verbs over #1166: - kube client: ApplySecret (server-side apply, key bytes kept in memory, no temp file) and GetSecretData. - internal/consensus/keys: Import builds the three per-node secrets (node<N>-gossip-keys / -grpc-tls-keys / -admin-pubkey) from a folder; Export writes them back for backup. The admin key is created in an external wallet; its public key is supplied as admin.pub in the folder and is the only admin material imported (created only when admin.pub exists, unless --admin is passed); the gossip signing secret is guarded against overwrite unless --force (it is the node's network identity). - commands: `consensus keys import` (--from, --source folder, --force, selectors; --node-id required) and `consensus keys export` (--out, selectors; --node-id required). Vault-backed import is tracked separately (#1171). Refs #1167 Signed-off-by: Lenin Mehedy <lenin.mehedy@hashgraph.com>
radkomih
force-pushed
the
01167-consensus-keys-import-export
branch
from
November 4, 2026 12:24
62c0dec to
9c786a7
Compare
radkomih
marked this pull request as ready for review
November 4, 2026 13:07
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Third PR in the stacked series for epic #1164 — Consensus Node Key & Secret Management. Stacked on #1197 (base branch
01166-consensus-keys-generate).Adds typed Kubernetes Secret I/O and the
import/exportverbs, turning a folder of key material into the per-node secrets the solo-operator consumes (and back).What's in it
ApplySecret(server-side apply; key bytes stay in memory, no temp file rendered) andGetSecretData.internal/consensus/keys—Importbuilds the three per-node secrets from a folder;Exportwrites them back to a folder for backup. Each key secret is named by the key's own date and fingerprint:node<N>-gossip-keys-<date>-<fp8>,node<N>-grpc-tls-keys-<date>-<fp8>,node<N>-admin-pubkey-<fp8>, with neutral, index-free inner-keys.<date>is the certificate'sNot beforedate (so reimporting the same folder after a cluster reset gives the same names) and<fp8>is the start of its SHA-384, taken over the PEM-encoded certificate (the same hash as the rostergrpc_certificate_hash). New key material therefore creates new secrets beside the old ones and never replaces them. Each secret carriessolo.hiero.org/node,key-typeandcert-fingerprintlabels plus SHA-384 andnot-afterannotations (see feat(consensus/keys): name key secrets by key date and fingerprint; stage rotations beside live keys #1282).consensus keys import—--keys-dir,--source folder(vault tracked in feat(consensus/keys): ESO/vault source for 'keys import' #1171),--force,--gossip/--tls/--admin;--node-idrequired. With no selector, the admin secret is created only whenadmin.pubexists in--keys-dir;--adminmakes it required.consensus keys export—--keys-dir, selectors;--node-idrequired.Custody & safety invariants
import --secret-suffix <text>replaces the date part;exporttakes--fingerprint/--secret-suffixto choose one generation, and checks each secret's content against its name, so a renamed or edited secret is refused.import --label key=value(repeatable) puts extra labels on every secret, for example a reference to an external system (example.com/external-ref=ticket-42). Kubernetes label syntax applies and weaver's own labels (solo.hiero.org/node,key-type,cert-fingerprint) are reserved. When a secret's content is already up to date, only its labels are patched: the key data is never sent again, so it cannot be overwritten.admin.pubin--keys-dir. Only that public key is imported; no admin private key ever reaches the provisioner or the cluster.importdecodes the hex inadmin.pub;exportwrites it back as hex. Storing the hex text would double-encode the key ingenesis-network.json. Operator follow-up: Read the admin public key secret as hex text only and label secp256k1 admin keys in genesis solo-operator#1394 proposes accepting hex text too.--forceis passed.admin.pubback; the admin private key stays in the wallet.Join flow this enables
keys generate(node-id-free) + wallet admin key → submitnodeCreateoff-cluster → network assigns the node-id → save the wallet's admin public key asadmin.pub→keys import --node-id <assigned>→consensus node install. solo-provisioner never submits the DAB transaction.Files
internal/kube/client.goApplySecret(SSA) +GetSecretDatainternal/kube/secret_test.goGetSecretDatatestsinternal/consensus/keys/secrets.goSecretClientiface,SecretNamesFor,Import/Exportinternal/consensus/keys/secrets_test.gocmd/cli/commands/consensus/keys/import.goimportsubcommandcmd/cli/commands/consensus/keys/export.goexportsubcommandcmd/cli/commands/consensus/keys/keys.gocmd/cli/commands/consensus/keys/import_export_test.godocs/commands/consensus.mdimport+exportsectionsTesting
Validated in the UTM VM:
All pass. The
ApplySecretserver-side-apply happy path is exercised via the orchestration tests (the fake dynamic client cannot create through SSA) and by UAT against a real cluster.Closes #1167.
Update: admin key generation was removed from the stack, so the VM run above predates that change. Unit tests pass on macOS for the touched packages; a VM run is still needed.