@@ -38,11 +38,13 @@ type RootOfTrust struct {
38
38
Verifiers []Verifier `json:"Verifiers"`
39
39
}
40
40
41
+ func (r * RootOfTrust ) IsPublic () bool {
42
+ return r .RekorPublicKey == "" && r .RootCert == "" && r .SCTPublicKey == ""
43
+ }
44
+
41
45
type Verifier struct {
42
46
Name string `json:"Name"`
43
47
Type string `json:"Type"`
44
- IgnoreTLog bool `json:"IgnoreTLog"`
45
- IgnoreSCT bool `json:"IgnoreSCT"`
46
48
KeyPairOptions VerifierKeyPairOptions `json:"KeyPairOptions"`
47
49
KeylessOptions VerifierKeylessOptions `json:"KeylessOptions"`
48
50
}
@@ -131,7 +133,7 @@ func verify(imgDigest v1.Hash, rootOfTrust RootOfTrust, sigs []oci.Signature) (s
131
133
}
132
134
for _ , verifier := range rootOfTrust .Verifiers {
133
135
fmt .Printf ("checking verifier %s\n " , verifier .Name )
134
- err = setVerifierCosignOptions (& cosignOptions , verifier , ctx )
136
+ err = setVerifierCosignOptions (& cosignOptions , verifier , rootOfTrust , ctx )
135
137
if err != nil {
136
138
return satisfiedVerifiers , fmt .Errorf ("could not set cosign options for verifier %s: %s" , verifier .Name , err .Error ())
137
139
}
@@ -214,7 +216,7 @@ func setRootOfTrustCosignOptions(cosignOptions *cosign.CheckOpts, rootOfTrust Ro
214
216
return nil
215
217
}
216
218
217
- func setVerifierCosignOptions (cosignOptions * cosign.CheckOpts , verifier Verifier , ctx context.Context ) (err error ) {
219
+ func setVerifierCosignOptions (cosignOptions * cosign.CheckOpts , verifier Verifier , rootOfTrust RootOfTrust , ctx context.Context ) (err error ) {
218
220
switch verifier .Type {
219
221
case "keypair" :
220
222
cosignOptions .SigVerifier , err = sig .LoadPublicKeyRaw ([]byte (verifier .KeyPairOptions .PublicKey ), crypto .SHA256 )
@@ -231,7 +233,13 @@ func setVerifierCosignOptions(cosignOptions *cosign.CheckOpts, verifier Verifier
231
233
default :
232
234
return fmt .Errorf ("invalid verification type in config file, must be either \" keypair\" or \" keyless\" , got \" %s\" " , verifier .Type )
233
235
}
234
- cosignOptions .IgnoreTlog = verifier .IgnoreTLog
235
- cosignOptions .IgnoreSCT = verifier .IgnoreSCT
236
+ if ! rootOfTrust .IsPublic () {
237
+ if rootOfTrust .RekorPublicKey == "" {
238
+ cosignOptions .IgnoreTlog = true
239
+ }
240
+ if rootOfTrust .SCTPublicKey == "" {
241
+ cosignOptions .IgnoreSCT = true
242
+ }
243
+ }
236
244
return nil
237
245
}
0 commit comments