Skip to content

[cli] tsig add read TSIG keys from file only - #938

Merged
withjannisNLnetLabs merged 4 commits into
mainfrom
tsig-add-yaml
Aug 27, 2026
Merged

[cli] tsig add read TSIG keys from file only#938
withjannisNLnetLabs merged 4 commits into
mainfrom
tsig-add-yaml

Conversation

@withjannisNLnetLabs

@withjannisNLnetLabs withjannisNLnetLabs commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

The cli should promote best practices, therefore the ability to add TSIG keys visible over the cli should not be possible. Additionally the cli UX should be unified with the other commands throughout the cli.

  • minimal dependencies
  • explicit command interface (no file format guessing)
  • yaml'ish file is default because it is also supported by nsd/unbound and can be read/written by a lot of tools through yaml.
  • dnst might support the generation of tsig keys in the yaml'ish format aswell
$ cat key.yaml
tsig-key:
       name: test.key
       algorithm: hmac-sha256
       secret: "B22jiD30pKL541XsOZ28y+NxbcIRoGqnumH2SFC8QDE="
$ cascade tsig add key.yaml
...
$ cat key.bind
key "tsig-key" {
        algorithm hmac-sha256;
        secret "pmUZPN18Id5O6ejGwp28YL0d3qa6AQ5X891TXD/iITM=";
};
$ cascade tsig add key.yaml
...

References

resolves #898 "Drop support for supplying TSIG secret on the CLI, support NSD/Unbound's TSIG config snippet format"
resolves #709 "TSIG secret can also be a path to a file, but what's the formula?"
resolves #706 "Possible enhancement: cascade tsig add from BIND-compatible TSIG key files"
resolves #609 "Is Base64 encoded TSIG secret key material passed to tsig add ambiguous?"


  • If you are changing Rust code or integration tests (Cargo.*, crates/, etc/, integration-tests/, src/):

    • Did you run the integration tests with act through the act-wrapper (as described in TESTING.md)?
  • If you are adding/deleting man pages:

    • Did you update the man_pages config in doc/manual/source/conf.py?
    • Did you update the packaged man pages in the Cargo.toml?
    • Did you commit the freshly built man pages?
  • If you are modifying man pages:

    • Did you commit the updated built man pages?

@withjannisNLnetLabs
withjannisNLnetLabs force-pushed the tsig-add-yaml branch 8 times, most recently from ccfa1c3 to 5929f7a Compare August 6, 2026 15:44
@withjannisNLnetLabs
withjannisNLnetLabs force-pushed the tsig-add-yaml branch 3 times, most recently from 2c9d3aa to 1b86d28 Compare August 13, 2026 13:17
@bal-e

bal-e commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Might solve #709.

@bal-e

bal-e commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Might solve #609.

Comment thread crates/cli/src/commands/tsig.rs Outdated
}
let tsig_alg = TsigAlgorithm::from_str(&tsig_alg_raw, true).map_err(|_| {
format!(
"Unable to parse {} possible values are {:?}",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explicitly mention that the argument that could not be parsed is the TSIG algorithm field.

Comment thread crates/cli/src/commands/tsig.rs Outdated
_ => unreachable!("Excluded via Clap 'requires' rules"),
};
let tsig_name = TsigKeyName::from_str(&tsig_name_raw)
.map_err(|err| format!("Invalid TSIG key name: {err}"))?;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe show tsig_name_raw here?

Comment thread crates/cli/src/commands/tsig.rs Outdated
line if line.starts_with(keywords.0) => name = Some(value_cleanup(line, &format)?),
line if line.starts_with(keywords.1) => algorithm = Some(value_cleanup(line, &format)?),
line if line.starts_with(keywords.2) => secret = Some(value_cleanup(line, &format)?),
_ => (),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Detect unexpected lines (i.e. not comment, not blank, not tsig-key:) and report an error.

Comment thread crates/cli/src/commands/tsig.rs Outdated
Comment on lines +292 to +294
line if line.starts_with(keywords.0) => name = Some(value_cleanup(line, &format)?),
line if line.starts_with(keywords.1) => algorithm = Some(value_cleanup(line, &format)?),
line if line.starts_with(keywords.2) => secret = Some(value_cleanup(line, &format)?),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Report an error if any of name, algorithm, secret are Some already.

@withjannisNLnetLabs
withjannisNLnetLabs force-pushed the tsig-add-yaml branch 2 times, most recently from 7871448 to 276a848 Compare August 24, 2026 15:35
@withjannisNLnetLabs
withjannisNLnetLabs marked this pull request as ready for review August 24, 2026 15:59
@ximon18 ximon18 added the cli Relating to the `cascade` CLI tool, which talks to the daemon. label Aug 26, 2026

@bal-e bal-e left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks awesome, well done :)

@withjannisNLnetLabs withjannisNLnetLabs changed the title [cli] Add support for TSIG keys in yaml file [cli] tsig add read TSIG keys from file only Aug 27, 2026
@withjannisNLnetLabs
withjannisNLnetLabs merged commit a23975f into main Aug 27, 2026
9 checks passed
@withjannisNLnetLabs
withjannisNLnetLabs deleted the tsig-add-yaml branch August 27, 2026 09:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli Relating to the `cascade` CLI tool, which talks to the daemon.

Projects

None yet

3 participants