Skip to content

Commit

Permalink
fixing issue 3426 (#3427)
Browse files Browse the repository at this point in the history
* fixing issue 3426

Signed-off-by: Mukuls77 <mukul.sharma@nokia.com>

* Fixed issue 3426

Signed-off-by: Mukuls77 <mukul.sharma@nokia.com>

* fix for issue 3426

Signed-off-by: Mukuls77 <mukul.sharma@nokia.com>

---------

Signed-off-by: Mukuls77 <mukul.sharma@nokia.com>
Co-authored-by: Mukuls77 <mukul.sharma@nokia.com>
  • Loading branch information
Mukuls77 and MukulSharma77 committed Dec 13, 2023
1 parent b3726e4 commit 0cb7ae9
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
15 changes: 14 additions & 1 deletion cmd/cosign/cli/verify/verify.go
Expand Up @@ -207,7 +207,7 @@ func (c *VerifyCommand) Exec(ctx context.Context, images []string) (err error) {
certRef := c.CertRef

// Ignore Signed Certificate Timestamp if the flag is set or a key is provided
if !c.IgnoreSCT || keylessVerification(c.KeyRef, c.Sk) {
if shouldVerifySCT(c.IgnoreSCT, c.KeyRef, c.Sk) {
co.CTLogPubKeys, err = cosign.GetCTLogPubs(ctx)
if err != nil {
return fmt.Errorf("getting ctlog public keys: %w", err)
Expand Down Expand Up @@ -500,3 +500,16 @@ func keylessVerification(keyRef string, sk bool) bool {
}
return true
}

func shouldVerifySCT(ignoreSCT bool, keyRef string, sk bool) bool {
if keyRef != "" {
return false
}
if sk {
return false
}
if ignoreSCT {
return false
}
return true
}
2 changes: 1 addition & 1 deletion cmd/cosign/cli/verify/verify_attestation.go
Expand Up @@ -111,7 +111,7 @@ func (c *VerifyAttestationCommand) Exec(ctx context.Context, images []string) (e
co.ClaimVerifier = cosign.IntotoSubjectClaimVerifier
}
// Ignore Signed Certificate Timestamp if the flag is set or a key is provided
if !c.IgnoreSCT || keylessVerification(c.KeyRef, c.Sk) {
if shouldVerifySCT(c.IgnoreSCT, c.KeyRef, c.Sk) {
co.CTLogPubKeys, err = cosign.GetCTLogPubs(ctx)
if err != nil {
return fmt.Errorf("getting ctlog public keys: %w", err)
Expand Down
2 changes: 1 addition & 1 deletion cmd/cosign/cli/verify/verify_blob.go
Expand Up @@ -286,7 +286,7 @@ func (c *VerifyBlobCmd) Exec(ctx context.Context, blobRef string) error {
}

// Ignore Signed Certificate Timestamp if the flag is set or a key is provided
if !c.IgnoreSCT || keylessVerification(c.KeyRef, c.Sk) {
if shouldVerifySCT(c.IgnoreSCT, c.KeyRef, c.Sk) {
co.CTLogPubKeys, err = cosign.GetCTLogPubs(ctx)
if err != nil {
return fmt.Errorf("getting ctlog public keys: %w", err)
Expand Down
2 changes: 1 addition & 1 deletion cmd/cosign/cli/verify/verify_blob_attestation.go
Expand Up @@ -190,7 +190,7 @@ func (c *VerifyBlobAttestationCommand) Exec(ctx context.Context, artifactPath st
}
}
// Ignore Signed Certificate Timestamp if the flag is set or a key is provided
if !c.IgnoreSCT || keylessVerification(c.KeyRef, c.Sk) {
if shouldVerifySCT(c.IgnoreSCT, c.KeyRef, c.Sk) {
co.CTLogPubKeys, err = cosign.GetCTLogPubs(ctx)
if err != nil {
return fmt.Errorf("getting ctlog public keys: %w", err)
Expand Down

0 comments on commit 0cb7ae9

Please sign in to comment.