public FileResource generateSignature(FileResource download, TempFile extensionFile, SignatureKeyPair keyPair) {
        var resource = new FileResource();
        resource.setExtension(download.getExtension());
        resource.setName(NamingUtil.toFileFormat(download.getExtension(), ".sigzip"));
        resource.setType(FileResource.DOWNLOAD_SIG);
        try (var out = new ByteArrayOutputStream()) {
            try (var zip = new ZipOutputStream(out)) {
                var sigEntry = new ZipEntry(".signature.sig");
                zip.putNextEntry(sigEntry);
                zip.write(generateSignature(extensionFile, keyPair));
                zip.closeEntry();

                var manifestEntry = new ZipEntry(".signature.manifest");
                zip.putNextEntry(manifestEntry);
                zip.write(generateSignatureManifest(extensionFile));
                zip.closeEntry();

                // Add dummy file to the archive because VS Code checks if it exists
                var dummyEntry = new ZipEntry(".signature.p7s");
                zip.putNextEntry(dummyEntry);
                zip.write(new byte[0]);
                zip.closeEntry();
            }

            resource.setContent(out.toByteArray());
        } catch (IOException e) {
            throw new ErrorResultException("Failed to sign extension file", e);
        }

        return resource;
    }
@Test
    public void testGenerateSignature() throws IOException {
        var keyPair = keyPairService.generateKeyPair();

        var namespace = new Namespace();
        namespace.setName("foo");

        var extension = new Extension();
        extension.setName("bar");
        extension.setNamespace(namespace);

        var extVersion = new ExtensionVersion();
        extVersion.setVersion("1.0.0");
        extVersion.setTargetPlatform("universal");
        extVersion.setExtension(extension);

        var download = new FileResource();
        download.setExtension(extVersion);

        var sigzipContent = new byte[0];
        try (
                var stream = getClass().getResource("ms-python.python-2024.7.11511013.vsix").openStream();
                var extensionFile = new TempFile("ms-python", ".vsix");
                var out = Files.newOutputStream(extensionFile.getPath())
        ) {
            stream.transferTo(out);
            var signature = integrityService.generateSignature(download, extensionFile, keyPair);
            sigzipContent = signature.getContent();
        }

        try(var temp = new TempFile("ms-python", ".sigzip")) {
            Files.write(temp.getPath(), sigzipContent);
            try (
                    var sigzip = new ZipFile(temp.getPath().toFile());
                    var expectedSigZip = new ZipFile(getClass().getResource("ms-python.python-2024.7.11511013.sigzip").getPath())
            ) {
                expectedSigZip.stream()
                        .forEach(expectedEntry -> {
                            var entry = sigzip.getEntry(expectedEntry.getName());
                            assertNotNull(entry);
                            if(expectedEntry.getName().equals(".signature.manifest")) {
                                assertEquals(
                                        new String(ArchiveUtil.readEntry(expectedSigZip, expectedEntry, ObservationRegistry.NOOP)),
                                        new String(ArchiveUtil.readEntry(sigzip, entry, ObservationRegistry.NOOP))
                                );
                            }
                        });

                var entry = sigzip.getEntry(".signature.sig");
                assertNotNull(entry);
                assertTrue(ArchiveUtil.readEntry(sigzip, entry, ObservationRegistry.NOOP).length > 0);
            }
        }
    }