Skip to content

Add --token-file flag to step ca certificate#1625

Open
ohhmkar wants to merge 2 commits into
smallstep:masterfrom
ohhmkar:master
Open

Add --token-file flag to step ca certificate#1625
ohhmkar wants to merge 2 commits into
smallstep:masterfrom
ohhmkar:master

Conversation

@ohhmkar
Copy link
Copy Markdown

@ohhmkar ohhmkar commented May 11, 2026

Name of feature:

Add --token-file flag to the step ca certificate command.

Pain or issue this feature alleviates:

It alleviates the need to manage tokens via STDOUT/STDIN or cumbersome shell variables when automating certificate issuance. step ca token already supports writing to disk via --output-file, but step ca certificate lacked a matching parameter to read that token back from disk.

Why is this important to the project (if not answered above):

It brings consistency between the token and certificate commands, providing a much cleaner UX for programmatic scripted workflows that rely on creating a token in one step and using it in another.

Is there documentation on how to use this feature? If so, where?

Addition is noted in CHANGELOG.md and documented in CLI Usage/help

In what environments or workflows is this feature supported?

In what environments or workflows is this feature explicitly NOT supported (if any)?

Logically incompatible with the '--token' and '--offline' flag. Command will return Error

Supporting links/other PRs/issues:

#1435
Fixes #1435
💔Thank you!

Copilot AI review requested due to automatic review settings May 11, 2026 18:38
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented May 11, 2026

CLA assistant check
All committers have signed the CLA.

@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@github-actions github-actions Bot added the needs triage Waiting for discussion / prioritization by team label May 11, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds support for providing a one-time token to step ca certificate via a file path, aligning the certificate issuance workflow with existing token-generation workflows that can write tokens to disk.

Changes:

  • Add --token-file flag to step ca certificate and load/trim the token contents from the provided file.
  • Add basic flag incompatibility checks between --token-file, --token, and --offline.
  • Document the new flag in CHANGELOG.md.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
command/ca/certificate.go Introduces the --token-file flag and reads the token from disk during certificate issuance.
CHANGELOG.md Notes the addition of --token-file for step ca certificate.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread command/ca/certificate.go
Comment on lines 239 to +250
tok := ctx.String("token")
tokenFile := ctx.String("token-file")
offline := ctx.Bool("offline")
sans := ctx.StringSlice("san")

switch {
case tok != "" && tokenFile != "":
return errs.IncompatibleFlagWithFlag(ctx, "token", "token-file")
case offline && tok != "":
// offline and token are incompatible because the token is generated before
// the start of the offline CA.
return errs.IncompatibleFlagWithFlag(ctx, "offline", "token")
case offline && tokenFile != "":
return errs.IncompatibleFlagWithFlag(ctx, "offline", "token-file")
Comment thread command/ca/certificate.go
if err != nil {
return err
}
tok = strings.TrimSpace(string(b))
Comment thread command/ca/certificate.go Outdated
…y exclusive

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs triage Waiting for discussion / prioritization by team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow step ca certificate to read token from a file

4 participants