@@ -325,31 +325,36 @@ verify_cosign() {
325325 local checksums_path=" $2 "
326326 local tmpdir=" $3 "
327327
328+ # Try bundle verification first (cosign v3+ / sigstore bundle)
329+ local bundle_url=" https://github.com/${GITHUB_REPO} /releases/download/${version} /SHA256SUMS.sigstore.json"
330+ local bundle_path=" ${tmpdir} /SHA256SUMS.sigstore.json"
331+
332+ if curl -sL --fail " $bundle_url " -o " $bundle_path " 2> /dev/null; then
333+ info " Verifying Cosign signature (bundle)..."
334+ cosign verify-blob " $checksums_path " \
335+ --bundle " $bundle_path " \
336+ --certificate-oidc-issuer " https://token.actions.githubusercontent.com" \
337+ --certificate-identity-regexp " github.com/gruntwork-io/terragrunt" 2> /dev/null
338+ return $?
339+ fi
340+
341+ # Legacy .sig/.pem verification (older releases without bundle)
328342 local sig_url=" https://github.com/${GITHUB_REPO} /releases/download/${version} /SHA256SUMS.sig"
329343 local cert_url=" https://github.com/${GITHUB_REPO} /releases/download/${version} /SHA256SUMS.pem"
330344 local sig_path=" ${tmpdir} /SHA256SUMS.sig"
331345 local cert_path=" ${tmpdir} /SHA256SUMS.pem"
332346
333347 info " Downloading Cosign signature files..."
334- if ! curl -sL --fail " $sig_url " -o " $sig_path " 2> /dev/null; then
335- warn " Failed to download Cosign signature file"
336- return 1
337- fi
338- if ! curl -sL --fail " $cert_url " -o " $cert_path " 2> /dev/null; then
339- warn " Failed to download Cosign certificate file"
340- return 1
341- fi
348+ curl -sL --fail " $sig_url " -o " $sig_path " 2> /dev/null || { warn " Failed to download Cosign signature file" ; return 1; }
349+ curl -sL --fail " $cert_url " -o " $cert_path " 2> /dev/null || { warn " Failed to download Cosign certificate file" ; return 1; }
342350
343351 info " Verifying Cosign signature..."
344- if cosign verify-blob " $checksums_path " \
352+ cosign verify-blob " $checksums_path " \
345353 --signature " $sig_path " \
346354 --certificate " $cert_path " \
347355 --certificate-oidc-issuer " https://token.actions.githubusercontent.com" \
348- --certificate-identity-regexp " github.com/gruntwork-io/terragrunt" 2> /dev/null; then
349- return 0
350- else
351- return 1
352- fi
356+ --certificate-identity-regexp " github.com/gruntwork-io/terragrunt" 2> /dev/null
357+ return $?
353358}
354359
355360# Verify signature using specified method
0 commit comments