Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add bundle to x509 needs-renewal command. #873

Merged
merged 8 commits into from
Mar 9, 2023
Merged

Conversation

dopey
Copy link
Contributor

@dopey dopey commented Mar 9, 2023

Fixes #870

  • Fixes unexpected behavior of implicitly applying needs-renewal to every cert in the bundle

- Fixes unexpected behavior of implicitly applying needs-renewal to every cert
  in the bundle
@dopey dopey requested a review from maraino March 9, 2023 17:47
@github-actions github-actions bot added the needs triage Waiting for discussion / prioritization by team label Mar 9, 2023
Copy link
Collaborator

@maraino maraino left a comment

Choose a reason for hiding this comment

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

The old code has also an exit code 2 that is not documented.

cli.BoolFlag{
Name: `bundle`,
Usage: `Check all certificates in the order in which they appear in the bundle.
By default (without this flag) this command will only check the leaf certificate.`,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think the default option can be clarified in the description.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is documented just below in the exit codes section.

@dopey dopey requested a review from maraino March 9, 2023 18:26
@@ -22,13 +23,16 @@ func needsRenewalCommand() cli.Command {
Action: cli.ActionFunc(needsRenewalAction),
Usage: `Check if a certificate needs to be renewed`,
UsageText: `**step certificate needs-renewal** <cert-file or hostname>
[**--expires-in**=<percent|duration>] [**--roots**=<root-bundle>] [**--servername**=<servername>]`,
[**--expires-in**=<percent|duration>] [**--bundle] [**--verbose]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Two missing **

Copy link
Collaborator

@maraino maraino left a comment

Choose a reason for hiding this comment

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

I was wrong about the verbose. We're already showing something if we DO NOT NEED to renew. We can remove the option or add a message something if the certificate NEEDS to be renewed.

@@ -48,11 +52,22 @@ Check if certificate.crt has passed 66 percent of its validity period:
$ step certificate needs-renewal ./certificate.crt
'''

Check if any certificate in the bundle has passed 66 percent of it's validity period:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Clarify in the first example that is the leaf certificate. Check if the leaf certificate.crt ...

Comment on lines 228 to 233
if isVerbose {
fmt.Println(needsRenewal)
}
if needsRenewal {
return nil
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I didn't know that when the certificate doesn't need renewal shows the following:

$ step certificate needs-renewal acme.crt
certificate does not need renewal

So perhaps the verbose option is not necessary.

Comment on lines 155 to 161
func isVerboseExit(needsRenewal, isVerbose bool) error {
if isVerbose {
fmt.Println(needsRenewal)
}
if needsRenewal {
return nil
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same comment as before. Perhaps show something only if needs renewal is false?

@dopey dopey requested a review from maraino March 9, 2023 21:07
},
cli.BoolFlag{
Name: "verbose, v",
Usage: `Return "true" or "false" in the terminal.`,
Copy link
Collaborator

Choose a reason for hiding this comment

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

The verbose usage is not right. We don't show true or false.

@@ -66,6 +68,10 @@ character. If using <duration>, the input must be a sequence of decimal numbers,
each with optional fraction and a unit suffix, such as "300ms", "-1.5h" or "2h45m".
Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".`,
},
cli.BoolFlag{
Name: "verbose, v",
Usage: `Return "true" or "false" in the terminal.`,
Copy link
Collaborator

Choose a reason for hiding this comment

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

ditto.

@dopey dopey merged commit 72088a2 into master Mar 9, 2023
@dopey dopey deleted the max/bundle-needs-renewal branch March 9, 2023 23:43
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.

[Bug]: step certificate needs-renewal should only run against leaf certificate by default.
2 participants