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

feat: resolve --cert from URL #1245

Merged
merged 1 commit into from
Dec 22, 2021
Merged
Show file tree
Hide file tree
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 cmd/cosign/cli/verify/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
"github.com/sigstore/cosign/cmd/cosign/cli/options"
"github.com/sigstore/cosign/cmd/cosign/cli/rekor"
"github.com/sigstore/cosign/cmd/cosign/cli/sign"
"github.com/sigstore/cosign/pkg/blob"
"github.com/sigstore/cosign/pkg/cosign"
"github.com/sigstore/cosign/pkg/cosign/pivkey"
"github.com/sigstore/cosign/pkg/cosign/pkcs11key"
Expand Down Expand Up @@ -131,7 +132,7 @@ func (c *VerifyCommand) Exec(ctx context.Context, images []string) (err error) {
return errors.Wrap(err, "initializing piv token verifier")
}
case certRef != "":
pubKey, err = loadCertFromFile(c.CertRef)
pubKey, err = loadCertFromFileOrURL(c.CertRef)
if err != nil {
return err
}
Expand Down Expand Up @@ -254,8 +255,8 @@ func PrintVerification(imgRef string, verified []oci.Signature, output string) {
}
}

func loadCertFromFile(path string) (*signature.ECDSAVerifier, error) {
pems, err := os.ReadFile(path)
func loadCertFromFileOrURL(path string) (*signature.ECDSAVerifier, error) {
pems, err := blob.LoadFileOrURL(path)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/cosign/cli/verify/verify_blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func VerifyBlobCmd(ctx context.Context, ko sign.KeyOpts, certRef, sigRef, blobRe
return errors.Wrap(err, "loading public key from token")
}
case certRef != "":
pubKey, err = loadCertFromFile(certRef)
pubKey, err = loadCertFromFileOrURL(certRef)
if err != nil {
return err
}
Expand Down