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

chore: fix documentation and warning on using untrusted rekor key #2124

Merged
merged 1 commit into from
Aug 3, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions pkg/cosign/tlog.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,12 @@ type RekorPubKey struct {

const (
// If specified, you can specify an oob Public Key that Rekor uses using
// this ENV variable. This ENV var is only for testing purposes.
// this ENV variable.
altRekorPublicKey = "SIGSTORE_REKOR_PUBLIC_KEY"
// Add Rekor API Public Key
// If specified, will fetch the Rekor Public Key from the specified Rekor
// server and add it to RekorPubKeys.
// server and add it to RekorPubKeys. This ENV var is only for testing
// purposes, as users should distribute keys out of band.
// TODO(vaikas): Implement storing state like Rekor does so that if tree
// state ever changes, it will make lots of noise.
addRekorPublicKeyFromRekor = "SIGSTORE_TRUST_REKOR_API_PUBLIC_KEY"
Expand Down Expand Up @@ -90,7 +91,6 @@ func GetRekorPubs(ctx context.Context, rekorClient *client.Rekor) (map[string]Re
altRekorPub := os.Getenv(altRekorPublicKey)

if altRekorPub != "" {
fmt.Fprintf(os.Stderr, "**Warning ('%s' is only for testing)** Using a non-standard public key for Rekor: %s\n", altRekorPublicKey, altRekorPub)
raw, err := os.ReadFile(altRekorPub)
if err != nil {
return nil, fmt.Errorf("error reading alternate Rekor public key file: %w", err)
Expand Down Expand Up @@ -130,6 +130,7 @@ func GetRekorPubs(ctx context.Context, rekorClient *client.Rekor) (map[string]Re
// additionally fetch it here.
addRekorPublic := os.Getenv(addRekorPublicKeyFromRekor)
if addRekorPublic != "" && rekorClient != nil {
fmt.Fprintf(os.Stderr, "**Warning ('%s' is only for testing)** Fetching public key from Rekor API directly\n", addRekorPublicKeyFromRekor)
pubOK, err := rekorClient.Pubkey.GetPublicKey(nil)
if err != nil {
return nil, fmt.Errorf("unable to fetch rekor public key from rekor: %w", err)
Expand Down