Skip to content

Commit

Permalink
feat: log error to stderr
Browse files Browse the repository at this point in the history
Signed-off-by: Batuhan Apaydın <batuhan.apaydin@trendyol.com>
  • Loading branch information
developer-guy committed Dec 30, 2021
1 parent 591601c commit e6de963
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions pkg/signature/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"context"
"crypto"
"crypto/x509"
"fmt"
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -139,13 +140,15 @@ func SignerVerifierFromKeyRef(ctx context.Context, keyRef string, pf cosign.Pass
return nil, err
}

return cosign.LoadECDSAPrivateKey([]byte(pk), []byte(pass))
default:
if sv, err := kms.Get(ctx, keyRef, crypto.SHA256); err == nil {
return sv, nil
}
return cosign.LoadECDSAPrivateKey([]byte(pk), []byte(pass)
}

sv, err := kms.Get(ctx, keyRef, crypto.SHA256)
if err == nil {
return sv, nil
}

fmt.Fprintf(os.Stderr, "an error occurred: %v, will try to load key from disk...\n", err)
return loadKey(keyRef, pf)
}

Expand Down

0 comments on commit e6de963

Please sign in to comment.