-
Notifications
You must be signed in to change notification settings - Fork 256
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 certificate extract command #574
Conversation
Hey @z8674558 thanks for the PR! Love that you added unit tests. You'll notice that we're not great at that ourselves. The first bit of feedback is that we'd like this command to be under the |
hi @dopey, that makes sense. I updated my code. do we want to also move |
To avoid breaking backward compatibility, I added |
We don't want to move # Current functionality:
## Format PEM to DER
step certificate format internal.pem [-out internal.der]
## Format DER to PEM
step certificate format internal.der [-out internal.pem]
# New functionality:
## Format PEM to P12
## We can default to p12 if --key or --ca are passed
step certificate format internal.pem [--format p12] --key internal.key --ca ca.pem [-out internal.p12]
## Format P12 to PEM
## We can default to PEM if the input is p12
### Print crt, ca, and key to stdout or file (in that order)
step certificate format internal.p12 [--format pem] [--out internal.pem]
### Print crt, ca, and key to different files
step certificate format internal.p12 --crt internal.pem --key internal.key --ca ca.pem
step certificate format internal.p12 --out internal.pem --key internal.key --ca ca.pem
### If this is confusing we might want to do
step certificate format internal.p12 --out internal.pem --out-key internal.key --out-ca ca.pem If you don't pass the out it will print in standard out. And of course, you can also do |
@maraino Looks nice, I updated my code. One concern from me is that this approach makes hard to print a single file to stdout. e.g. one have to do the following to print only a certificate from a p12 file:
I would propose that instead of printing to stdout when the flags are absent, we allow empty value in the flags. In the above example,
will print the certificate to stdout, ignoring the key and the intermediate CAs. With this approach, |
Yea, so, to state the obvious this is a little clunky because P12s can have CAs & keys while PEM/DER is typically just one cert. I think having both If you combine these flags (e.g., @z8674558, for your use case (writing an individual file to stdout) could we support |
@mmalone Thank you for the insight.
I adopted the strategy 1) for I don't think many people want to save crt, key, and ca into a single file. And they can just
This looks nice and I tried it. It turned out, however, |
Hey @z8674558 we really appreciate the contribution! We're still reviewing, but in the mean time we wanted to send you some swag to show our appreciation. If you're interested, ping me ([email protected]). Cheers! |
command/certificate/format.go
Outdated
Name: "format", | ||
Action: command.ActionFunc(formatAction), | ||
Usage: `reformat certificate`, | ||
UsageText: `**step certificate format** <crt_file> [**--out**=<file>]`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's leave the first arg as <crt-file>
. That name is consistent across the other commands, and I'm changing the other commands to use -
instead of _
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
command/certificate/format.go
Outdated
## POSITIONAL ARGUMENTS | ||
|
||
<crt_file> | ||
: Path to a certificate or CSR file. | ||
<src_file> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No description provided.
Created a new branch / PR because I wanted to commit some documentation changes - #589 |
Going to close this one in favor of the other if that's all right. Let me know if I should reopen |
Fixes #487
Description
Add
step certificate extract
command to extract a certificate and private key from a .p12 file, with corresponding integration tests.