Add CLI interface for the signing key

- 'signkey set' sets a new signing key (disables an old one if
  existing).
- 'signkey show' prints the fingerprint.
- 'signkey dump' prints the certificate of the signing key.
This commit is contained in:
Malte Meiboom
2026-06-13 14:37:37 +02:00
parent 7547776efe
commit 06c0583f5e
8 changed files with 207 additions and 25 deletions
+63 -3
View File
@@ -33,6 +33,7 @@ pub enum HuskSubcommands {
Daemon(DaemonCommand),
Introducer(IntroducerCommand),
Locals(LocalsCommand),
Signkey(SignkeyCommand),
}
// Daemon subcommands
@@ -76,6 +77,9 @@ pub struct IntroducerCommand {
pub enum IntroducerSubcommand {
Add(IntroducerAddCommand),
Remove(IntroducerRemoveCommand),
#[clap(
about = "List introducers."
)]
List
}
@@ -88,7 +92,8 @@ pub struct IntroducerAddCommand {
#[clap(
long = "cert",
help = "Certificate to declare as introducer.",
conflicts_with = "cert_file"
conflicts_with = "cert_file",
value_name = "FINGERPRINT",
)]
pub cert: Option<String>,
@@ -118,7 +123,8 @@ pub struct IntroducerAddCommand {
pub struct IntroducerRemoveCommand {
#[clap(
long = "cert",
help = "Certificate to be removed as introducer."
help = "Certificate to be removed as introducer.",
value_name = "FINGERPRINT",
)]
pub cert: String,
@@ -149,6 +155,9 @@ pub struct LocalsCommand {
pub enum LocalsSubcommand {
Add(LocalsAddCommand),
Remove(LocalsRemoveCommand),
#[clap(
about = "List locals."
)]
List
}
@@ -174,8 +183,59 @@ pub struct LocalsAddCommand {
pub struct LocalsRemoveCommand {
#[clap(
long = "cert",
help = "Certificate to be removed."
help = "Certificate to be removed.",
value_name = "FINGERPRINT",
)]
pub cert: String,
}
// Signkey subcommands
#[derive(Parser, Debug)]
#[clap(
name = "signkey",
about = "Manage the signing key.",
subcommand_required = true,
arg_required_else_help = true,
disable_colored_help = true,
disable_version_flag = true,
)]
pub struct SignkeyCommand {
#[clap(subcommand)]
pub subcommand: SignkeySubcommand,
}
#[derive(Debug, Subcommand)]
pub enum SignkeySubcommand {
Set(SignkeySetCommand),
#[clap(
about = "Show the fingerprint of the signing key."
)]
Show,
#[clap(
about = "Print the certificate of the signing key."
)]
Dump,
}
#[derive(Parser, Debug)]
#[clap(
about = "Set a new signing key.",
)]
pub struct SignkeySetCommand {
#[clap(
long,
help = "Load a new signing key from <FILE>.",
value_name = "FILE",
conflicts_with = "cert"
)]
pub cert_file: Option<String>,
#[clap(
long = "cert",
help = "Certificate to declare as signing key.",
conflicts_with = "cert_file",
value_name = "FINGERPRINT",
)]
pub cert: Option<String>,
}