@@ -553,8 +553,19 @@ public Manifest getManifest(ContainerRef containerRef) {
553553 throw new OrasException (
554554 "Expected manifest but got index. Probably a multi-platform image instead of artifact" );
555555 }
556- ManifestDescriptor manifestDescriptor = ManifestDescriptor .of (descriptor );
557- return Manifest .fromJson (descriptor .getJson ()).withDescriptor (manifestDescriptor );
556+ String json = descriptor .getJson ();
557+ String digest = descriptor .getDigest ();
558+ if (digest == null ) {
559+ LOG .debug ("Digest missing from header, using from reference" );
560+ digest = containerRef .getDigest ();
561+ if (digest == null ) {
562+ LOG .debug ("Digest missing from reference, computing from content" );
563+ digest = containerRef .getAlgorithm ().digest (json .getBytes (StandardCharsets .UTF_8 ));
564+ LOG .debug ("Computed index digest: {}" , digest );
565+ }
566+ }
567+ ManifestDescriptor manifestDescriptor = ManifestDescriptor .of (descriptor , digest );
568+ return Manifest .fromJson (json ).withDescriptor (manifestDescriptor );
558569 }
559570
560571 @ Override
@@ -649,7 +660,7 @@ private void validateDockerContentDigest(HttpClient.ResponseWrapper<String> resp
649660 // We need a way to propagate the headers like scoped.
650661 // For now just skip validation
651662 if (digest == null ) {
652- LOG .warn ("Docker-Content-Digest header not found in response. Skipping validation." );
663+ LOG .debug ("Docker-Content-Digest header not found in response. Skipping validation." );
653664 return ;
654665 }
655666 String computedDigest = SupportedAlgorithm .fromDigest (digest ).digest (data );
@@ -662,7 +673,7 @@ private void validateDockerContentDigest(HttpClient.ResponseWrapper<Path> respon
662673 // We need a way to propagate the headers like scoped.
663674 // For now just skip validation
664675 if (digest == null ) {
665- LOG .warn ("Docker-Content-Digest header not found in response. Skipping validation." );
676+ LOG .debug ("Docker-Content-Digest header not found in response. Skipping validation." );
666677 return ;
667678 }
668679 String computedDigest = SupportedAlgorithm .fromDigest (digest ).digest (path );
@@ -679,7 +690,7 @@ private void validateDockerContentDigest(HttpClient.ResponseWrapper<Path> respon
679690 // We need a way to propagate the headers like scoped.
680691 // For now just skip validation
681692 if (digest == null ) {
682- LOG .warn ("Docker-Content-Digest header not found in response. Skipping validation." );
693+ LOG .debug ("Docker-Content-Digest header not found in response. Skipping validation." );
683694 return null ;
684695 }
685696 SupportedAlgorithm .fromDigest (digest );
0 commit comments