@@ -38,7 +38,6 @@ import (
3838 csigs "github.com/sigstore/cosign/v2/pkg/signature"
3939 "github.com/sigstore/policy-controller/pkg/apis/config"
4040 policyduckv1beta1 "github.com/sigstore/policy-controller/pkg/apis/duck/v1beta1"
41- "github.com/sigstore/policy-controller/pkg/apis/policy/v1alpha1"
4241 policycontrollerconfig "github.com/sigstore/policy-controller/pkg/config"
4342 webhookcip "github.com/sigstore/policy-controller/pkg/webhook/clusterimagepolicy"
4443 rekor "github.com/sigstore/rekor/pkg/client"
@@ -1296,22 +1295,25 @@ func checkOptsFromAuthority(ctx context.Context, authority webhookcip.Authority,
12961295 ret .IntermediateCerts = fulcioIntermediates
12971296 ret .CTLogPubKeys = ctlogKeys
12981297 }
1299- rekorClient , rekorPubKeys , err := rekorClientAndKeysFromAuthority (ctx , authority . CTLog )
1298+ rekorClient , rekorPubKeys , err := rekorClientAndKeysFromAuthority (ctx , authority )
13001299 if err != nil {
13011300 return nil , fmt .Errorf ("getting Rekor public keys: %s: %w" , authority .Name , err )
13021301 }
13031302 ret .RekorClient = rekorClient
13041303 ret .RekorPubKeys = rekorPubKeys
1304+
13051305 // Skip the TLog verification if we have no client or keys to validate
13061306 // against.
13071307 if ret .RekorClient == nil {
1308- if ret .RekorPubKeys == nil {
1309- ret .IgnoreTlog = true
1310- } else {
1308+ if ret .RekorPubKeys != nil {
13111309 // If there's keys however, use offline for verification.
13121310 ret .Offline = true
1311+ } else {
1312+ // If there is not a rekor client definition then skip tlog verification.
1313+ ret .IgnoreTlog = true
13131314 }
13141315 }
1316+
13151317 if authority .RFC3161Timestamp != nil && authority .RFC3161Timestamp .TrustRootRef != "" {
13161318 logging .FromContext (ctx ).Debug ("Using RFC3161Timestamp..." )
13171319 // TODO: By default, we disable any tlog verification when using the RFC3161Timestamp validation.
@@ -1437,7 +1439,17 @@ func fulcioCertsFromAuthority(ctx context.Context, keylessRef *webhookcip.Keyles
14371439// Preference is given to TrustRoot if specified, from which the URL and public
14381440// keys are fetched and returned. If there's no TrustRoot but a URL, then
14391441// a Rekor client is returned and the keys from the embedded or cached TUF root.
1440- func rekorClientAndKeysFromAuthority (ctx context.Context , tlog * v1alpha1.TLog ) (* client.Rekor , * cosign.TrustedTransparencyLogPubKeys , error ) {
1442+ func rekorClientAndKeysFromAuthority (ctx context.Context , authority webhookcip.Authority ) (* client.Rekor , * cosign.TrustedTransparencyLogPubKeys , error ) {
1443+ // In keyless, if no TrustRoot was defined and CTLog is nil, then default to rekor pub keys as done in cosign
1444+ if authority .Keyless != nil && authority .Keyless .TrustRootRef == "" && authority .CTLog == nil {
1445+ rekorPubKeys , err := cosign .GetRekorPubs (ctx )
1446+ if err != nil {
1447+ logging .FromContext (ctx ).Errorf ("failed getting rekor public keys: %v" , err )
1448+ return nil , nil , fmt .Errorf ("getting Rekor public keys: %w" , err )
1449+ }
1450+ return nil , rekorPubKeys , nil
1451+ }
1452+ tlog := authority .CTLog
14411453 if tlog == nil {
14421454 return nil , nil , nil
14431455 }
0 commit comments