Skip to content

feat(consensus/keys): add consensus keys inspect - #1279

Open
leninmehedy wants to merge 1 commit into
01195-consensus-keys-initfrom
01278-consensus-keys-inspect
Open

leninmehedy wants to merge 1 commit into
01195-consensus-keys-initfrom
01278-consensus-keys-inspect

Conversation

@leninmehedy

@leninmehedy leninmehedy commented Oct 13, 2026 •

Copy link
Copy Markdown
Member

Closes #1278. Part of #1164. Stacked on #1200.

Summary

Operators had to run openssl x509 -text -noout to look at the certificates and public keys that consensus keys generates. consensus keys inspect does this in pure Go.

  • Works on a --keys-dir folder or a single --file (certificate PEM or admin public key hex). Supports --gossip/--tls/--admin and --output json.

  • Shows subject, issuer, validity with days remaining, signature algorithm, key type and size, SANs, key usage, SHA-256 (over the DER, like openssl x509 -fingerprint) and SHA-384 (over the PEM form, the same hash as the roster grpc_certificate_hash and the secret fingerprint) fingerprints, and the admin public key in hex.

  • Disk only. To inspect cluster secrets, run keys export first.

  • Private key files are never read, so nothing secret is loaded into memory. Use keys verify to check that keys match their certificates.

  • Section headings show the file and what it is, e.g. [hedera.crt | gRPC TLS certificate].

  • Files that are not in the folder are skipped and listed in a Not found (skipped) line. It exits non-zero only when no key file is found or a file does not parse.

  • loadDir is extracted from VerifyDir so both verbs share folder loading; verify behavior is unchanged.

  • Text output ends with a two-line reminder: openssl x509 -in <file> -text -noout for the full X.509 dump, and consensus keys verify to check that keys match their certificates (only when a certificate was shown).

  • The walkthrough shows the new date-and-fingerprint secret names.

  • Adds a "Try it: end-to-end walkthrough" section to docs/commands/consensus.md covering the whole keys family, with expected output.

Testing

  • go test ./internal/consensus/keys/... passes, including a test that inspect works with all private key files removed.
  • cmd/cli/commands/consensus/keys is Linux-only; it compiles for Linux (go vet), and the command tests (including the walkthrough steps) still need a VM run.

Risks

None for existing commands. verify only gained a private-key loading flag that it sets to true.

@leninmehedy
leninmehedy requested a review from a team as a code owner October 13, 2026 10:22
@leninmehedy
leninmehedy added this pull request to stack #1201 October 13, 2026 10:23
@swirlds-automation

swirlds-automation commented Oct 13, 2026 •

Copy link
Copy Markdown

✅ Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
✅ Open Source Security 0 0 0 0 0 issues
✅ Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@leninmehedy
leninmehedy force-pushed the 01278-consensus-keys-inspect branch 2 times, most recently from 5cc5d96 to ae9e27e Compare October 13, 2026 10:39
@leninmehedy
leninmehedy force-pushed the 01278-consensus-keys-inspect branch from ae9e27e to 593446b Compare October 13, 2026 11:06
@leninmehedy
leninmehedy force-pushed the 01278-consensus-keys-inspect branch from 593446b to 25bb9d9 Compare October 13, 2026 11:29
@leninmehedy
leninmehedy force-pushed the 01278-consensus-keys-inspect branch from 25bb9d9 to b6e642d Compare October 13, 2026 12:37
@leninmehedy
leninmehedy force-pushed the 01278-consensus-keys-inspect branch from b6e642d to e3fd9f3 Compare October 13, 2026 12:52
@leninmehedy
leninmehedy marked this pull request as draft October 20, 2026 06:24
@leninmehedy leninmehedy added the skip-kvm-runner Skip kvm-runner jobs (UAT, integration) in PR checks; for stacked PRs below the top label Oct 21, 2026
@leninmehedy
leninmehedy force-pushed the 01278-consensus-keys-inspect branch from e3fd9f3 to 926f389 Compare October 21, 2026 03:38
@leninmehedy
leninmehedy force-pushed the 01278-consensus-keys-inspect branch from 926f389 to 47f17fd Compare October 21, 2026 04:44
@leninmehedy
leninmehedy force-pushed the 01278-consensus-keys-inspect branch from 47f17fd to 87f6891 Compare October 21, 2026 05:19
Show certificate and public key details (subject, issuer, validity,
signature algorithm, key type and size, SANs, key usage, fingerprints,
admin public key) from a key folder or a single file, replacing
`openssl x509 -text -noout`. Disk only: cluster secrets are inspected by
exporting them first. Private key files are never read.

Extract loadDir from VerifyDir so both verbs share folder loading.

Closes #1278

Signed-off-by: Lenin Mehedy <lenin.mehedy@hashgraph.com>
@radkomih
radkomih force-pushed the 01278-consensus-keys-inspect branch from 87f6891 to f393316 Compare November 4, 2026 12:47
@radkomih
radkomih marked this pull request as ready for review November 4, 2026 13:06
@radkomih
radkomih requested review from a team as code owners November 4, 2026 13:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-kvm-runner Skip kvm-runner jobs (UAT, integration) in PR checks; for stacked PRs below the top

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(consensus/keys): 'consensus keys inspect' to view certs and public keys without openssl

2 participants