@@ -253,32 +253,18 @@ func GetLocalBlobPath(ctx context.Context, src types.ImageSource, digest digest.
253253func (s * ociImageSource ) GetSignaturesWithFormat (ctx context.Context , instanceDigest * digest.Digest ) ([]signature.Signature , error ) {
254254 if instanceDigest == nil {
255255 if s .descriptor .Digest == "" {
256- return nil , errors .New ("unknown manifest digest, can't add signatures" )
256+ return nil , errors .New ("unknown manifest digest, can't get signatures" )
257257 }
258258 instanceDigest = & s .descriptor .Digest
259259 }
260- signTag , err := sigstoreAttachmentTag (* instanceDigest )
261- if err != nil {
262- return nil , err
263- }
264260
265- var signDigest * digest.Digest
266- for _ , m := range s .index .Manifests {
267- if m .Annotations [imgspecv1 .AnnotationRefName ] == signTag {
268- signDigest = & m .Digest
269- break
270- }
271- }
272- if signDigest == nil {
273- return nil , errors .New ("no signature found for image" )
274- }
275- signBlob , _ , err := s .GetManifest (ctx , signDigest )
261+ ociManifest , err := s .ref .getSigstoreAttachmentManifest (* instanceDigest , s .index , s .sharedBlobDir )
276262 if err != nil {
277263 return nil , err
278264 }
279- ociManifest , err := manifest . OCI1FromManifest ( signBlob )
280- if err != nil {
281- return nil , err
265+ if ociManifest == nil {
266+ // No signature found
267+ return nil , nil
282268 }
283269
284270 signatures := make ([]signature.Signature , 0 , len (ociManifest .Layers ))
@@ -290,7 +276,7 @@ func (s *ociImageSource) GetSignaturesWithFormat(ctx context.Context, instanceDi
290276 defer layerBlob .Close ()
291277 payload , err := iolimits .ReadAtMost (layerBlob , iolimits .MaxSignatureBodySize )
292278 if err != nil {
293- return nil , fmt .Errorf ("reading blob %s in %s: %w" , layer .Digest .String (), signTag , err )
279+ return nil , fmt .Errorf ("reading blob %s in %s: %w" , layer .Digest .String (), instanceDigest , err )
294280 }
295281 actualDigest := layer .Digest .Algorithm ().FromBytes (payload )
296282 if actualDigest != layer .Digest {
0 commit comments