Skip to content
This repository was archived by the owner on Sep 23, 2025. It is now read-only.

Commit bfc8bc4

Browse files
committed
revert: keyless ctlog to rekor.sigstore.dev
Signed-off-by: Hector Fernandez <hector@chainguard.dev>
1 parent 5ab8174 commit bfc8bc4

3 files changed

Lines changed: 20 additions & 9 deletions

File tree

pkg/webhook/validator.go

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

pkg/webhook/validator_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2994,7 +2994,7 @@ func TestRekorClientAndKeysFromAuthority(t *testing.T) {
29942994
if tCtx == nil {
29952995
tCtx = context.Background()
29962996
}
2997-
rekorClient, gotPKs, err := rekorClientAndKeysFromAuthority(tCtx, tc.tlog)
2997+
rekorClient, gotPKs, err := rekorClientAndKeysFromAuthority(tCtx, webhookcip.Authority{CTLog: tc.tlog})
29982998
if err != nil {
29992999
if tc.wantErr == "" {
30003000
t.Errorf("unexpected error: %v wanted none", err)

test/testdata/policy-controller/e2e/cip-key-and-keyless.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,4 @@ spec:
3636
identities:
3737
- issuerRegExp: .*kubernetes.default.*
3838
subjectRegExp: .*kubernetes.io/namespaces/default/serviceaccounts/default
39-
ctlog:
40-
url: http://rekor.sigstore.dev
39+

0 commit comments

Comments
 (0)