Skip to content

Commit 702db8b

Browse files
authored
Fix scaffolding trust root (#1486)
* workflows: Add a test that uses trusted_root.json Scaffolding TUF setup includes a generated trusted_root.json but it is never tested: Add a cosign invocation that does so. Signed-off-by: Jussi Kukkonen <[email protected]> * repo: Use correct-er LogID calculation logid used in trusted_root.json (which is an artifact in the TUF repository that scaffolding generates) is a hash of **DER** key. Signed-off-by: Jussi Kukkonen <[email protected]> --------- Signed-off-by: Jussi Kukkonen <[email protected]>
1 parent 527c985 commit 702db8b

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

.github/workflows/fulcio-rekor-kind.yaml

+16
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,22 @@ jobs:
176176
--certificate-identity "https://kubernetes.io/namespaces/default/serviceaccounts/default" \
177177
--certificate-oidc-issuer "https://kubernetes.default.svc.cluster.local"
178178
179+
- name: Sign a blob with signature bundle format
180+
run: |
181+
cosign sign-blob --yes --new-bundle-format=true --bundle=bundle.json --rekor-url $REKOR_URL --fulcio-url $FULCIO_URL --identity-token $OIDC_TOKEN README.md
182+
183+
- name: Verify blob with signature bundle format using trusted_root.json
184+
run: |
185+
# the trusted_root.json is in the TUF target cache: Use --trusted-root while cosign does not
186+
# use it by default
187+
cosign verify-blob \
188+
--certificate-identity-regexp="https://kubernetes.io/namespaces/default/serviceaccounts/default" \
189+
--certificate-oidc-issuer-regexp="https://kubernetes.default.svc.cluster.local" \
190+
--bundle=bundle.json --new-bundle-format \
191+
--rekor-url $REKOR_URL \
192+
--trusted-root=$HOME/.sigstore/root/targets/trusted_root.json \
193+
README.md
194+
179195
# Test with cosign in 'airgapped mode'
180196
# Uncomment these once modified cosign goes in.
181197
#- name: Checkout modified cosign for testing.

pkg/repo/repo.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,8 @@ func constructTrustedRoot(targets []TargetWithMetadata) (*TargetWithMetadata, er
287287
}
288288

289289
func pubkeyToTransparencyLogInstance(keyBytes []byte, tm time.Time) (*root.TransparencyLog, string, error) {
290-
logID := sha256.Sum256(keyBytes)
291290
der, _ := pem.Decode(keyBytes)
291+
logID := sha256.Sum256(der.Bytes)
292292
key, keyDetails, err := getKeyWithDetails(der.Bytes)
293293
if err != nil {
294294
return nil, "", err

0 commit comments

Comments
 (0)