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

Improve public key output and add file output #194

Merged
merged 2 commits into from
Jan 26, 2023

Conversation

Gronner
Copy link
Contributor

@Gronner Gronner commented Jan 16, 2023

Summary

As described in #105 the output provided by the example get_public_key was not pretty. It included quotation marks at the beginning and the and, as well as the newline characters \n.
In addition this prevented piping the output of the example into a file, as it would include the quotation marks and the newline characters. Now using cargo run --example get_public_key > key.pub the public key can be stored in a file in the PEM format.

In addition it can be useful to directly store the public key in a file instead of piping to a file.

Release Note

The Rekor example get_public_key was expanded to:

  • use Display printing
  • provide a command line option to store the public key in a file

Documentation

Close #105

@Gronner Gronner force-pushed the output_get_public_key_example branch from 2219ff0 to f406ffd Compare January 16, 2023 20:23
Previously Debug printing was used to output the public key after
retrieval. Using Display printing the public key is displayed to the
command line as expected with line breaks.

In addition this commit adds --output,-o as arguments to store the
retrieved public key in a file.
To ease use a default value (key.pub) is provided, so that no parameter
needs to be given.

Resolves: #105
Signed-off-by: Gronner <felix.braeunling@t-online.de>
@Gronner Gronner force-pushed the output_get_public_key_example branch from f406ffd to 8afc7a5 Compare January 16, 2023 20:26
println!("{:#?}", pubkey.unwrap());

if let Some(out_path) = flags.get_one::<String>("output") {
match write(out_path, pubkey.unwrap()) {
Copy link
Member

Choose a reason for hiding this comment

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

nitpicking: instead of using unwrap use expect with a nice message. I would do that right on line 50, after the await.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, in the future it might be useful to enhance the errors get_public_key returns to enhance the possible feedback or by "unpacking" the information stored in the returned error.

Signed-off-by: Gronner <felix.braeunling@t-online.de>
@Gronner Gronner force-pushed the output_get_public_key_example branch from b1e4166 to bc370a4 Compare January 25, 2023 17:25
@flavio flavio merged commit d0744c8 into sigstore:main Jan 26, 2023
@Gronner Gronner deleted the output_get_public_key_example branch January 26, 2023 17:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Better output for Rekor get_public_key
2 participants