@@ -32,7 +32,6 @@ import (
3232 "strings"
3333
3434 "github.com/sigstore/cosign/v3/cmd/cosign/cli/options"
35- "github.com/sigstore/cosign/v3/cmd/cosign/cli/rekor"
3635 "github.com/sigstore/cosign/v3/internal/ui"
3736 "github.com/sigstore/cosign/v3/pkg/blob"
3837 "github.com/sigstore/cosign/v3/pkg/cosign"
@@ -184,39 +183,12 @@ func (c *VerifyBlobCmd) Exec(ctx context.Context, blobRef string) error {
184183 } else if c .RFC3161TimestampPath == "" && co .UseSignedTimestamps {
185184 return fmt .Errorf ("when specifying --use-signed-timestamps or --timestamp-certificate-chain, you must also specify --rfc3161-timestamp-path" )
186185 }
187- if co .UseSignedTimestamps && co .TrustedMaterial == nil {
188- tsaCertificates , err := cosign .GetTSACerts (ctx , c .TSACertChainPath , cosign .GetTufTargets )
189- if err != nil {
190- return fmt .Errorf ("unable to load TSA certificates: %w" , err )
191- }
192- co .TSACertificate = tsaCertificates .LeafCert
193- co .TSARootCertificates = tsaCertificates .RootCert
194- co .TSAIntermediateCertificates = tsaCertificates .IntermediateCerts
195- }
196186
197- if ! c .IgnoreTlog {
198- if c .RekorURL != "" {
199- rekorClient , err := rekor .NewClient (c .RekorURL )
200- if err != nil {
201- return fmt .Errorf ("creating Rekor client: %w" , err )
202- }
203- co .RekorClient = rekorClient
204- }
205- if co .TrustedMaterial == nil {
206- // This performs an online fetch of the Rekor public keys, but this is needed
207- // for verifying tlog entries (both online and offline).
208- co .RekorPubKeys , err = cosign .GetRekorPubs (ctx )
209- if err != nil {
210- return fmt .Errorf ("getting Rekor public keys: %w" , err )
211- }
212- }
187+ err = SetLegacyClientsAndKeys (ctx , c .IgnoreTlog , shouldVerifySCT (c .IgnoreSCT , c .KeyRef , c .Sk ), keylessVerification (c .KeyRef , c .Sk ), c .RekorURL , c .TSACertChainPath , c .CertChain , c .CARoots , c .CAIntermediates , co )
188+ if err != nil {
189+ return fmt .Errorf ("setting up clients and keys: %w" , err )
213190 }
214191
215- if co .TrustedMaterial == nil && keylessVerification (c .KeyRef , c .Sk ) {
216- if err := loadCertsKeylessVerification (c .CertChain , c .CARoots , c .CAIntermediates , co ); err != nil {
217- return err
218- }
219- }
220192 opts := make ([]static.Option , 0 )
221193 if c .BundlePath != "" {
222194 b , err := cosign .FetchLocalSignedPayloadFromPath (c .BundlePath )
@@ -310,14 +282,6 @@ func (c *VerifyBlobCmd) Exec(ctx context.Context, blobRef string) error {
310282 opts = append (opts , static .WithCertChain (certPEM , chainPEM ))
311283 }
312284
313- // Ignore Signed Certificate Timestamp if the flag is set or a key is provided
314- if co .TrustedMaterial == nil && shouldVerifySCT (c .IgnoreSCT , c .KeyRef , c .Sk ) {
315- co .CTLogPubKeys , err = cosign .GetCTLogPubs (ctx )
316- if err != nil {
317- return fmt .Errorf ("getting ctlog public keys: %w" , err )
318- }
319- }
320-
321285 sig , err := base64signature (c .SigRef , c .BundlePath )
322286 if err != nil {
323287 return err
0 commit comments