@@ -30,11 +30,12 @@ type Configuration struct {
30
30
}
31
31
32
32
type RootOfTrust struct {
33
- Name string `json:"Name"`
34
- RekorPublicKey string `json:"RekorPublicKey"`
35
- RootCert string `json:"RootCert"`
36
- SCTPublicKey string `json:"SCTPublicKey"`
37
- Verifiers []Verifier `json:"Verifiers"`
33
+ Name string `json:"Name"`
34
+ RootlessKeypairsOnly bool `json:"RootlessKeypairsOnly"`
35
+ RekorPublicKey string `json:"RekorPublicKey"`
36
+ RootCert string `json:"RootCert"`
37
+ SCTPublicKey string `json:"SCTPublicKey"`
38
+ Verifiers []Verifier `json:"Verifiers"`
38
39
}
39
40
40
41
func (r * RootOfTrust ) IsPublic () bool {
@@ -191,9 +192,13 @@ func verify(imgDigest v1.Hash, rootOfTrust RootOfTrust, sigs []oci.Signature, pr
191
192
}
192
193
193
194
func setRootOfTrustCosignOptions (cosignOptions * cosign.CheckOpts , rootOfTrust RootOfTrust , proxy Proxy , ctx context.Context ) (err error ) {
195
+ if rootOfTrust .RootlessKeypairsOnly {
196
+ return nil
197
+ }
198
+
194
199
// rekor public keys
195
200
rekorKeyCollection := cosign .NewTrustedTransparencyLogPubKeys ()
196
- if rootOfTrust .RekorPublicKey == "" {
201
+ if rootOfTrust .IsPublic () {
197
202
rekorKeyTargets , err := GetSigstorePublicTufTargets (sigtuf .Rekor , proxy )
198
203
if err != nil {
199
204
return fmt .Errorf ("could not retrieve rekor tuf targets: %s" , err .Error ())
@@ -203,7 +208,7 @@ func setRootOfTrustCosignOptions(cosignOptions *cosign.CheckOpts, rootOfTrust Ro
203
208
return fmt .Errorf ("could not add public root of trust rekor public key to collection: %w" , err )
204
209
}
205
210
}
206
- } else {
211
+ } else if rootOfTrust . RekorPublicKey != "" {
207
212
if err := rekorKeyCollection .AddTransparencyLogPubKey ([]byte (rootOfTrust .RekorPublicKey ), sigtuf .Active ); err != nil {
208
213
return fmt .Errorf ("could not add custom root of trust rekor public key to collection: %w" , err )
209
214
}
@@ -233,7 +238,7 @@ func setRootOfTrustCosignOptions(cosignOptions *cosign.CheckOpts, rootOfTrust Ro
233
238
}
234
239
cosignOptions .RootCerts = rootPool
235
240
cosignOptions .IntermediateCerts = intermediatePool
236
- } else {
241
+ } else if rootOfTrust . IsPublic () {
237
242
targetCertificates , err := GetSigstorePublicTufTargets (sigtuf .Fulcio , proxy )
238
243
// certificates, err := GetPublicRootOfTrustFulcioCertificates(proxy)
239
244
if err != nil {
@@ -263,7 +268,7 @@ func setRootOfTrustCosignOptions(cosignOptions *cosign.CheckOpts, rootOfTrust Ro
263
268
264
269
// sct public keys
265
270
sctKeyCollection := cosign .NewTrustedTransparencyLogPubKeys ()
266
- if rootOfTrust .SCTPublicKey == "" {
271
+ if rootOfTrust .IsPublic () {
267
272
sctKeyTargets , err := GetSigstorePublicTufTargets (sigtuf .CTFE , proxy )
268
273
if err != nil {
269
274
return fmt .Errorf ("could not retrieve ctfe tuf targets: %s" , err .Error ())
@@ -273,7 +278,7 @@ func setRootOfTrustCosignOptions(cosignOptions *cosign.CheckOpts, rootOfTrust Ro
273
278
return fmt .Errorf ("could not add public root of trust sct public key to collection: %w" , err )
274
279
}
275
280
}
276
- } else {
281
+ } else if rootOfTrust . SCTPublicKey != "" {
277
282
if err := sctKeyCollection .AddTransparencyLogPubKey ([]byte (rootOfTrust .SCTPublicKey ), sigtuf .Active ); err != nil {
278
283
return fmt .Errorf ("could not add custom root of trust sct public key to collection: %w" , err )
279
284
}
@@ -291,6 +296,12 @@ func setVerifierCosignOptions(cosignOptions *cosign.CheckOpts, verifier Verifier
291
296
return fmt .Errorf ("could not load PEM encoded public key of verifier %s under %s: %s" , verifier .Name , rootOfTrust .Name , err .Error ())
292
297
}
293
298
case "keyless" :
299
+ if rootOfTrust .RootlessKeypairsOnly {
300
+ return fmt .Errorf ("cannot use keyless verifier for root of trust with field RootlessKeypairsOnly set to true" )
301
+ }
302
+ if rootOfTrust .RootCert == "" && ! rootOfTrust .IsPublic () {
303
+ return fmt .Errorf ("cannot use keyless verifier %s with private root of trust without root cert" , verifier .Name )
304
+ }
294
305
cosignOptions .Identities = []cosign.Identity {
295
306
{
296
307
Issuer : verifier .KeylessOptions .CertIssuer ,
@@ -309,5 +320,9 @@ func setVerifierCosignOptions(cosignOptions *cosign.CheckOpts, verifier Verifier
309
320
cosignOptions .IgnoreSCT = true
310
321
}
311
322
}
323
+ if rootOfTrust .RootlessKeypairsOnly {
324
+ cosignOptions .IgnoreSCT = true
325
+ cosignOptions .IgnoreTlog = true
326
+ }
312
327
return nil
313
328
}
0 commit comments