Repository navigation
Conversation
Signing is not deterministic: the Unity attestation carries an RFC 3161 timestamp, so signing identical content produces a different tarball, a different SHA-1 and a different published checksum. A full rebuild (image update) therefore rewrites the checksum of every package, which invalidates downstream mirrors and caches for no reason. Record the SHA-256 of the unsigned tarball next to each signed package and reuse the signed artifact when a rebuild produces the same unsigned bytes. The conversion now writes the unsigned tarball to a sibling file, hashes it, and only calls the signer when the digest differs from the recorded one. forceUpdate no longer deletes signed packages up front, so the reuse path can see the previous artifact; the conversion still runs for every version. The recorded digest is removed together with the package, and a failed conversion keeps the previous signed artifact when it was reused.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Every build of a package runs
upm pack, and signing is not deterministic: the attestation embeds an RFC 3161 timestamp, so the same content signed twice produces different bytes. The signed tarball, its SHA-1 and thedist.shasumin the registry metadata therefore change on every rebuild, even when the package content is identical.This happens on every image update, because a changed registry version clears the cache and regenerates all packages. Downstream mirrors and clients then see a checksum change for packages that did not change, and anything caching by checksum has to re-download everything.
Change
<file>.tgz.unsigned, hashed with SHA-256, and moved into place only when it has to be signed.<file>.tgz.unsigned.sha256after signing..sha1are present, the existing signed package is kept and the signer is not called.forceUpdateno longer deletes signed packages before the conversion, so the reuse path can see them; the conversion still runs for every version.Packages without a recorded digest (all existing ones) are signed once, then start reusing.
Validation
dotnet buildclean, no warnings.dotnet test src/UnityNuGet.Tests— 504 passed, 22 skipped, 1 failure:CanParse_PackageWithRuntimes, which also fails on the unmodified branch here (it downloads a package from nuget.org), so it is unrelated.upmexecutable that behaves like the real signer (new bytes on every run): two consecutive forced rebuilds produced byte-identical artifacts with this change, and different artifacts without it.Notes